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.

1580 lines
51 KiB

  1. /****************************************************************************\
  2. *
  3. * advdlg.cpp
  4. *
  5. * Created: William Taylor (wtaylor) 01/22/01
  6. *
  7. * MS Ratings Advanced Property Page
  8. *
  9. \****************************************************************************/
  10. #include "msrating.h"
  11. #include "mslubase.h"
  12. #include "parselbl.h"
  13. #include "picsrule.h"
  14. #include "advdlg.h" // CAdvancedDialog
  15. // #include "custfile.h" // CCustomFileDialog
  16. #include "debug.h" // TraceMsg()
  17. #include <contxids.h> // Help Context ID's
  18. #include <mluisupp.h> // SHWinHelpOnDemandWrap() and MLLoadStringA()
  19. // $KLUDGE begins -- These should not be a global set outside the class!!
  20. extern PICSRulesRatingSystem * g_pPRRS;
  21. extern array<PICSRulesRatingSystem*> g_arrpPRRS;
  22. extern array<PICSRulesRatingSystem*> g_arrpPICSRulesPRRSPreApply;
  23. extern HANDLE g_HandleGlobalCounter,g_ApprovedSitesHandleGlobalCounter;
  24. extern long g_lGlobalCounterValue,g_lApprovedSitesGlobalCounterValue;
  25. // $KLUDGE ends -- These should not be a global set outside the class!!
  26. DWORD CAdvancedDialog::aIds[] = {
  27. IDC_TEXT1, IDH_RATINGS_BUREAU,
  28. IDC_TEXT2, IDH_RATINGS_BUREAU,
  29. IDC_TEXT3, IDH_RATINGS_BUREAU,
  30. IDC_3RD_COMBO, IDH_RATINGS_BUREAU,
  31. IDC_STATIC_PICSRULES, IDH_IGNORE,
  32. IDC_STATIC_PICSRULES2, IDH_IGNORE,
  33. IDC_PICSRULESOPEN, IDH_PICSRULES_OPEN,
  34. IDC_PICSRULESEDIT, IDH_PICSRULES_EDIT,
  35. IDC_PICSRULES_UP, IDH_ADVANCED_TAB_UP_ARROW_BUTTON,
  36. IDC_PICSRULES_DOWN, IDH_ADVANCED_TAB_DOWN_ARROW_BUTTON,
  37. IDC_STATIC1, IDH_IGNORE,
  38. IDC_PICSRULES_LIST, IDH_PICS_RULES_LIST,
  39. 0,0
  40. };
  41. CAdvancedDialog::CAdvancedDialog( PRSD * p_pPRSD )
  42. {
  43. ASSERT( p_pPRSD );
  44. m_pPRSD = p_pPRSD;
  45. }
  46. LRESULT CAdvancedDialog::OnSysColorChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  47. {
  48. HWND hDlg = m_hWnd;
  49. HICON hIcon, hOldIcon;
  50. hIcon = (HICON) LoadImage(g_hInstance,
  51. MAKEINTRESOURCE(IDI_PICSRULES_UP),
  52. IMAGE_ICON,
  53. 16,
  54. 16,
  55. LR_LOADTRANSPARENT|LR_DEFAULTCOLOR|LR_CREATEDIBSECTION);
  56. hOldIcon=(HICON) SendDlgItemMessage(IDC_PICSRULES_UP,BM_SETIMAGE,(WPARAM) IMAGE_ICON,(LPARAM) hIcon);
  57. if(hOldIcon!=NULL)
  58. {
  59. DeleteObject(hOldIcon);
  60. }
  61. hIcon = (HICON) LoadImage(g_hInstance,
  62. MAKEINTRESOURCE(IDI_PICSRULES_DOWN),
  63. IMAGE_ICON,
  64. 16,
  65. 16,
  66. LR_LOADTRANSPARENT|LR_DEFAULTCOLOR|LR_CREATEDIBSECTION);
  67. hOldIcon=(HICON) SendDlgItemMessage(IDC_PICSRULES_DOWN,BM_SETIMAGE,(WPARAM) IMAGE_ICON,(LPARAM) hIcon);
  68. if(hOldIcon!=NULL)
  69. {
  70. DeleteObject(hOldIcon);
  71. }
  72. return 0L;
  73. }
  74. LRESULT CAdvancedDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  75. {
  76. HICON hIcon;
  77. int iCounter;
  78. PRSD * pPRSD = m_pPRSD;
  79. ASSERT( pPRSD );
  80. if ( ! pPRSD )
  81. {
  82. TraceMsg( TF_ERROR, "CAdvancedDialog::OnInitDialog() - pPRSD is NULL!" );
  83. return 0L;
  84. }
  85. FillBureauList( pPRSD->pPRSI);
  86. hIcon = (HICON) LoadImage(g_hInstance,
  87. MAKEINTRESOURCE(IDI_PICSRULES_UP),
  88. IMAGE_ICON,
  89. 16,
  90. 16,
  91. LR_LOADTRANSPARENT|LR_DEFAULTCOLOR|LR_CREATEDIBSECTION);
  92. SendDlgItemMessage(IDC_PICSRULES_UP,BM_SETIMAGE,(WPARAM) IMAGE_ICON,(LPARAM) hIcon);
  93. hIcon = (HICON) LoadImage(g_hInstance,
  94. MAKEINTRESOURCE(IDI_PICSRULES_DOWN),
  95. IMAGE_ICON,
  96. 16,
  97. 16,
  98. LR_LOADTRANSPARENT|LR_DEFAULTCOLOR|LR_CREATEDIBSECTION);
  99. SendDlgItemMessage(IDC_PICSRULES_DOWN,BM_SETIMAGE,(WPARAM) IMAGE_ICON,(LPARAM) hIcon);
  100. g_arrpPICSRulesPRRSPreApply.DeleteAll();
  101. if(g_lGlobalCounterValue!=SHGlobalCounterGetValue(g_HandleGlobalCounter))
  102. {
  103. HRESULT hRes;
  104. DWORD dwNumSystems;
  105. PICSRulesRatingSystem * pPRRS=NULL;
  106. g_arrpPRRS.DeleteAll();
  107. //someone modified our settings, so we'd better reload them.
  108. hRes=PICSRulesGetNumSystems(&dwNumSystems);
  109. if(SUCCEEDED(hRes))
  110. {
  111. DWORD dwCounter;
  112. for(dwCounter=PICSRULES_FIRSTSYSTEMINDEX;
  113. dwCounter<(dwNumSystems+PICSRULES_FIRSTSYSTEMINDEX);
  114. dwCounter++)
  115. {
  116. hRes=PICSRulesReadFromRegistry(dwCounter,&pPRRS);
  117. if(FAILED(hRes))
  118. {
  119. //we couldn't read in the systems, so don't inforce PICSRules,
  120. //and notify the user
  121. g_arrpPRRS.DeleteAll();
  122. MyMessageBox(m_hWnd, IDS_PICSRULES_TAMPEREDREADMSG, IDS_PICSRULES_TAMPEREDREADTITLE, MB_OK|MB_ICONERROR );
  123. break;
  124. }
  125. else
  126. {
  127. g_arrpPRRS.Append(pPRRS);
  128. pPRRS=NULL;
  129. }
  130. }
  131. }
  132. g_lGlobalCounterValue=SHGlobalCounterGetValue(g_HandleGlobalCounter);
  133. }
  134. CopyArrayPRRSStructures(&g_arrpPICSRulesPRRSPreApply,&g_arrpPRRS);
  135. //fill in the listbox with installed PICSRules systems
  136. for(iCounter=0;iCounter<g_arrpPICSRulesPRRSPreApply.Length();iCounter++)
  137. {
  138. PICSRulesRatingSystem * pPRRSToList;
  139. char * lpszName=NULL;
  140. pPRRSToList=g_arrpPICSRulesPRRSPreApply[iCounter];
  141. if((pPRRSToList->m_pPRName)!=NULL)
  142. {
  143. lpszName=pPRRSToList->m_pPRName->m_etstrRuleName.Get();
  144. }
  145. if(lpszName==NULL)
  146. {
  147. lpszName=pPRRSToList->m_etstrFile.Get();
  148. }
  149. // We should have a name in lpszName by now, but just in case, check for it.
  150. if (lpszName)
  151. {
  152. SendDlgItemMessage(IDC_PICSRULES_LIST,LB_ADDSTRING,(WPARAM) 0,(LPARAM) lpszName);
  153. }
  154. }
  155. SendDlgItemMessage(IDC_PICSRULES_LIST,LB_SETCURSEL,(WPARAM) -1,(LPARAM) 0);
  156. ::EnableWindow(GetDlgItem(IDC_PICSRULESEDIT),FALSE);
  157. if(SendDlgItemMessage( IDC_PICSRULES_LIST, LB_GETCOUNT, 0, 0) < 2)
  158. {
  159. // less than 2 elements in box - disable up and down buttons
  160. ::EnableWindow(GetDlgItem( IDC_PICSRULES_UP), FALSE);
  161. ::EnableWindow(GetDlgItem( IDC_PICSRULES_DOWN), FALSE);
  162. }
  163. PostMessage(WM_USER,(WPARAM) 0,(LPARAM) 0);
  164. bHandled = FALSE;
  165. return 1L; // Let the system set the focus
  166. }
  167. LRESULT CAdvancedDialog::OnUser(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  168. {
  169. if (gPRSI->lpszFileName!=NULL)
  170. {
  171. ::SetFocus(GetDlgItem(IDC_PICSRULESOPEN));
  172. SendMessage(WM_COMMAND,(WPARAM) IDC_PICSRULESOPEN,(LPARAM) 0);
  173. gPRSI->lpszFileName=NULL;
  174. }
  175. return 0L;
  176. }
  177. LRESULT CAdvancedDialog::OnMarkChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  178. {
  179. MarkChanged();
  180. return 1L;
  181. }
  182. LRESULT CAdvancedDialog::OnSelChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  183. {
  184. ::EnableWindow(GetDlgItem(IDC_PICSRULESEDIT),TRUE);
  185. return 1L;
  186. }
  187. LRESULT CAdvancedDialog::OnPicsRulesUp(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  188. {
  189. int iSelected;
  190. PICSRulesRatingSystem * pPRRSToMove;
  191. char * lpszName=NULL;
  192. iSelected= (int) SendDlgItemMessage(IDC_PICSRULES_LIST,
  193. LB_GETCURSEL,
  194. (WPARAM) 0,
  195. (LPARAM) 0);
  196. if(iSelected==LB_ERR)
  197. {
  198. return 1L;
  199. }
  200. if(iSelected==0)
  201. {
  202. //already at the top
  203. return 1L;
  204. }
  205. pPRRSToMove=g_arrpPICSRulesPRRSPreApply[iSelected];
  206. g_arrpPICSRulesPRRSPreApply[iSelected]=
  207. g_arrpPICSRulesPRRSPreApply[iSelected-1];
  208. g_arrpPICSRulesPRRSPreApply[iSelected-1]=pPRRSToMove;
  209. //update the listbox
  210. SendDlgItemMessage(IDC_PICSRULES_LIST,
  211. LB_DELETESTRING,
  212. (WPARAM) iSelected,
  213. (LPARAM) 0);
  214. SendDlgItemMessage(IDC_PICSRULES_LIST,
  215. LB_DELETESTRING,
  216. (WPARAM) iSelected-1,
  217. (LPARAM) 0);
  218. pPRRSToMove=g_arrpPICSRulesPRRSPreApply[iSelected-1];
  219. if((pPRRSToMove->m_pPRName)!=NULL)
  220. {
  221. lpszName=pPRRSToMove->m_pPRName->m_etstrRuleName.Get();
  222. }
  223. if(lpszName==NULL)
  224. {
  225. lpszName=pPRRSToMove->m_etstrFile.Get();
  226. }
  227. SendDlgItemMessage(IDC_PICSRULES_LIST,
  228. LB_INSERTSTRING,
  229. (WPARAM) iSelected-1,
  230. (LPARAM) lpszName);
  231. pPRRSToMove=g_arrpPICSRulesPRRSPreApply[iSelected];
  232. if((pPRRSToMove->m_pPRName)!=NULL)
  233. {
  234. lpszName=pPRRSToMove->m_pPRName->m_etstrRuleName.Get();
  235. }
  236. if(lpszName==NULL)
  237. {
  238. lpszName=pPRRSToMove->m_etstrFile.Get();
  239. }
  240. SendDlgItemMessage(IDC_PICSRULES_LIST,
  241. LB_INSERTSTRING,
  242. (WPARAM) iSelected,
  243. (LPARAM) lpszName);
  244. SendDlgItemMessage(IDC_PICSRULES_LIST,
  245. LB_SETCURSEL,
  246. (WPARAM) iSelected-1,
  247. (LPARAM) 0);
  248. MarkChanged();
  249. return 1L;
  250. }
  251. LRESULT CAdvancedDialog::OnPicsRulesDown(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  252. {
  253. int iSelected, iNumItems;
  254. PICSRulesRatingSystem * pPRRSToMove;
  255. char * lpszName=NULL;
  256. iSelected= (int) SendDlgItemMessage(IDC_PICSRULES_LIST,
  257. LB_GETCURSEL,
  258. (WPARAM) 0,
  259. (LPARAM) 0);
  260. if(iSelected==LB_ERR)
  261. {
  262. return 1L;
  263. }
  264. iNumItems= (int) SendDlgItemMessage(IDC_PICSRULES_LIST,
  265. LB_GETCOUNT,
  266. (WPARAM) 0,
  267. (LPARAM) 0);
  268. if(iNumItems==LB_ERR)
  269. {
  270. return 1L;
  271. }
  272. if(iSelected==(iNumItems-1))
  273. {
  274. //already at the bottom
  275. return 1L;
  276. }
  277. pPRRSToMove=g_arrpPICSRulesPRRSPreApply[iSelected];
  278. g_arrpPICSRulesPRRSPreApply[iSelected]=
  279. g_arrpPICSRulesPRRSPreApply[iSelected+1];
  280. g_arrpPICSRulesPRRSPreApply[iSelected+1]=pPRRSToMove;
  281. //update the listbox
  282. SendDlgItemMessage(IDC_PICSRULES_LIST,
  283. LB_DELETESTRING,
  284. (WPARAM) iSelected+1,
  285. (LPARAM) 0);
  286. SendDlgItemMessage(IDC_PICSRULES_LIST,
  287. LB_DELETESTRING,
  288. (WPARAM) iSelected,
  289. (LPARAM) 0);
  290. pPRRSToMove=g_arrpPICSRulesPRRSPreApply[iSelected];
  291. if((pPRRSToMove->m_pPRName)!=NULL)
  292. {
  293. lpszName=pPRRSToMove->m_pPRName->m_etstrRuleName.Get();
  294. }
  295. if(lpszName==NULL)
  296. {
  297. lpszName=pPRRSToMove->m_etstrFile.Get();
  298. }
  299. SendDlgItemMessage(IDC_PICSRULES_LIST,
  300. LB_INSERTSTRING,
  301. (WPARAM) iSelected,
  302. (LPARAM) lpszName);
  303. pPRRSToMove=g_arrpPICSRulesPRRSPreApply[iSelected+1];
  304. if((pPRRSToMove->m_pPRName)!=NULL)
  305. {
  306. lpszName=pPRRSToMove->m_pPRName->m_etstrRuleName.Get();
  307. }
  308. if(lpszName==NULL)
  309. {
  310. lpszName=pPRRSToMove->m_etstrFile.Get();
  311. }
  312. SendDlgItemMessage(IDC_PICSRULES_LIST,
  313. LB_INSERTSTRING,
  314. (WPARAM) iSelected+1,
  315. (LPARAM) lpszName);
  316. SendDlgItemMessage(IDC_PICSRULES_LIST,
  317. LB_SETCURSEL,
  318. (WPARAM) iSelected+1,
  319. (LPARAM) 0);
  320. MarkChanged();
  321. return 1L;
  322. }
  323. LRESULT CAdvancedDialog::OnPicsRulesEdit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  324. {
  325. int iSelected, iCounter;
  326. array<PICSRulesRatingSystem*> g_arrpPICSRulesPRRSNew;
  327. iSelected= (int) SendDlgItemMessage(IDC_PICSRULES_LIST,
  328. LB_GETCURSEL,
  329. (WPARAM) 0,
  330. (LPARAM) 0);
  331. if(iSelected==LB_ERR)
  332. {
  333. return 1L;
  334. }
  335. SendDlgItemMessage(IDC_PICSRULES_LIST,
  336. LB_DELETESTRING,
  337. (WPARAM) iSelected,
  338. (LPARAM) 0);
  339. // If there's less than two left, turn off up and down buttons
  340. if(SendDlgItemMessage( IDC_PICSRULES_LIST, LB_GETCOUNT, 0, 0) < 2)
  341. {
  342. ::EnableWindow(GetDlgItem( IDC_PICSRULES_UP), FALSE);
  343. ::EnableWindow(GetDlgItem( IDC_PICSRULES_DOWN), FALSE);
  344. }
  345. delete (g_arrpPICSRulesPRRSPreApply[iSelected]);
  346. g_arrpPICSRulesPRRSPreApply[iSelected]=NULL;
  347. for(iCounter=0;iCounter<g_arrpPICSRulesPRRSPreApply.Length();iCounter++)
  348. {
  349. PICSRulesRatingSystem * pPRRSToMove;
  350. pPRRSToMove=g_arrpPICSRulesPRRSPreApply[iCounter];
  351. if(pPRRSToMove!=NULL)
  352. {
  353. g_arrpPICSRulesPRRSNew.Append(pPRRSToMove);
  354. }
  355. }
  356. g_arrpPICSRulesPRRSPreApply.ClearAll();
  357. for(iCounter=0;iCounter<g_arrpPICSRulesPRRSNew.Length();iCounter++)
  358. {
  359. PICSRulesRatingSystem * pPRRSToMove;
  360. pPRRSToMove=g_arrpPICSRulesPRRSNew[iCounter];
  361. g_arrpPICSRulesPRRSPreApply.Append(pPRRSToMove);
  362. }
  363. g_arrpPICSRulesPRRSNew.ClearAll();
  364. ::EnableWindow(GetDlgItem(IDC_PICSRULESEDIT),FALSE);
  365. MarkChanged();
  366. ::SetFocus(GetDlgItem(IDC_PICSRULESOPEN));
  367. SendDlgItemMessage(IDC_PICSRULESOPEN,
  368. BM_SETSTYLE,
  369. (WPARAM) BS_DEFPUSHBUTTON,
  370. (LPARAM) MAKELPARAM(TRUE,0));
  371. SendDlgItemMessage(IDC_PICSRULESEDIT,
  372. BM_SETSTYLE,
  373. (WPARAM) BS_PUSHBUTTON,
  374. (LPARAM) MAKELPARAM(TRUE,0));
  375. return 1L;
  376. }
  377. LRESULT CAdvancedDialog::OnPicsRulesOpen(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  378. {
  379. TCHAR szFile[MAX_PATH];
  380. szFile[0] = '\0';
  381. BOOL bExists=FALSE,fPICSRulesSaved=FALSE,fHaveFile=FALSE;
  382. PICSRulesRatingSystem *pPRRS;
  383. PRSD * pPRSD = m_pPRSD;
  384. if(!pPRSD)
  385. {
  386. MyMessageBox(m_hWnd, IDS_PICSRULES_SYSTEMERROR, IDS_ERROR, MB_OK|MB_ICONERROR);
  387. return 1L;
  388. }
  389. if (gPRSI->lpszFileName)
  390. {
  391. fHaveFile=TRUE;
  392. lstrcpy(szFile,gPRSI->lpszFileName);
  393. }
  394. else
  395. {
  396. TCHAR szDlgTitle[MAX_PATH];
  397. TCHAR szDlgFilter[MAX_PATH];
  398. LPTSTR pszDlgFilterPtr;
  399. memset( szDlgFilter, 0, sizeof( szDlgFilter ) );
  400. MLLoadString(IDS_OPENDIALOGFILTER,(LPTSTR) szDlgFilter,ARRAYSIZE(szDlgFilter));
  401. MLLoadString(IDS_OPENDIALOGTITLE,(LPTSTR) szDlgTitle,ARRAYSIZE(szDlgTitle));
  402. pszDlgFilterPtr = &szDlgFilter[lstrlen(szDlgFilter)+1];
  403. lstrcpy(pszDlgFilterPtr, TEXT("*.prf"));
  404. OPENFILENAME OpenFileName;
  405. memset( &OpenFileName, 0, sizeof(OpenFileName) );
  406. OpenFileName.lStructSize =sizeof(OPENFILENAME);
  407. OpenFileName.hwndOwner =m_hWnd;
  408. OpenFileName.hInstance =NULL;
  409. OpenFileName.lpstrFilter =szDlgFilter;
  410. OpenFileName.lpstrCustomFilter =(LPTSTR) NULL;
  411. OpenFileName.nMaxCustFilter =0L;
  412. OpenFileName.nFilterIndex =1L;
  413. OpenFileName.lpstrFile =szFile;
  414. OpenFileName.nMaxFile =ARRAYSIZE(szFile);
  415. OpenFileName.lpstrInitialDir =NULL;
  416. OpenFileName.lpstrTitle =szDlgTitle;
  417. OpenFileName.nFileOffset =0;
  418. OpenFileName.nFileExtension =0;
  419. OpenFileName.lpstrDefExt =NULL;
  420. OpenFileName.lCustData =0;
  421. OpenFileName.Flags =OFN_FILEMUSTEXIST
  422. | OFN_PATHMUSTEXIST
  423. | OFN_HIDEREADONLY;
  424. fHaveFile = ::GetOpenFileName( &OpenFileName );
  425. #ifdef NEVER
  426. DWORD dwFlags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_NONETWORKBUTTON
  427. | OFN_HIDEREADONLY;
  428. CCustomFileDialog cfd( TRUE, // Local Files Only
  429. TRUE, // Open File
  430. NULL, // Default Extension
  431. NULL, // Initial Filename
  432. dwFlags, // Open File Flags
  433. szDlgFilter, // Filter
  434. m_hWnd ); // Parent
  435. if ( cfd.DoModal( m_hWnd ) )
  436. {
  437. fHaveFile = TRUE;
  438. lstrcpy( szFile, cfd.m_szFileName );
  439. }
  440. #endif
  441. }
  442. if (fHaveFile)
  443. {
  444. HRESULT hRes;
  445. //create PICSRulesRatingSystem class, and pass to the
  446. //import procedure with file name
  447. hRes=PICSRulesImport(szFile,&pPRRS);
  448. if(SUCCEEDED(hRes))
  449. {
  450. LPSTR lpszPICSRulesSystemName = NULL,lpszNewSystemName = NULL;
  451. DWORD dwSystemToSave,dwNumSystemsInstalled,dwCounter;
  452. BOOL fPromptToOverwrite=FALSE;
  453. if((pPRRS->m_pPRName)!=NULL)
  454. {
  455. lpszNewSystemName=pPRRS->m_pPRName->m_etstrRuleName.Get();
  456. }
  457. if(lpszNewSystemName==NULL)
  458. {
  459. lpszNewSystemName=pPRRS->m_etstrFile.Get();
  460. }
  461. dwNumSystemsInstalled=g_arrpPICSRulesPRRSPreApply.Length();
  462. //Systems below PICSRULES_FIRSTSYSTEMINDEX are
  463. //reserved for the Approved Sites Rules, and
  464. //future expansion.
  465. for(dwCounter=0;dwCounter<dwNumSystemsInstalled;dwCounter++)
  466. {
  467. //check to see if the system we just processed
  468. //is already installed
  469. if ((g_arrpPICSRulesPRRSPreApply[dwCounter])->m_pPRName != NULL)
  470. {
  471. lpszPICSRulesSystemName=(g_arrpPICSRulesPRRSPreApply[dwCounter])->m_pPRName->m_etstrRuleName.Get();
  472. }
  473. if (lpszPICSRulesSystemName == NULL)
  474. {
  475. lpszPICSRulesSystemName=(g_arrpPICSRulesPRRSPreApply[dwCounter])->m_etstrFile.Get();
  476. }
  477. if(lstrcmp(lpszPICSRulesSystemName,lpszNewSystemName)==0)
  478. {
  479. //We've found an identical system, so set dwSystemToSave
  480. //to dwCounter and set fPromptToOverwrite to TRUE
  481. fPromptToOverwrite=TRUE;
  482. return 1L;
  483. }
  484. }
  485. dwSystemToSave=dwCounter+PICSRULES_FIRSTSYSTEMINDEX;
  486. if(fPromptToOverwrite)
  487. {
  488. if (IDNO == MyMessageBox(m_hWnd, IDS_PICSRULES_EXISTSMESSAGE, IDS_PICSRULES_EXISTSTITLE, MB_YESNO|MB_ICONERROR))
  489. {
  490. delete pPRRS;
  491. pPRRS=NULL;
  492. g_pPRRS=NULL;
  493. return 1L;
  494. }
  495. }
  496. if((dwSystemToSave-PICSRULES_FIRSTSYSTEMINDEX)<(DWORD) (g_arrpPICSRulesPRRSPreApply.Length()))
  497. {
  498. char * lpszName=NULL;
  499. delete g_arrpPICSRulesPRRSPreApply[dwSystemToSave-PICSRULES_FIRSTSYSTEMINDEX];
  500. g_arrpPICSRulesPRRSPreApply[dwSystemToSave-PICSRULES_FIRSTSYSTEMINDEX]=pPRRS;
  501. //update the listbox
  502. if((pPRRS->m_pPRName)!=NULL)
  503. {
  504. lpszName=pPRRS->m_pPRName->m_etstrRuleName.Get();
  505. }
  506. if(lpszName==NULL)
  507. {
  508. lpszName=pPRRS->m_etstrFile.Get();
  509. }
  510. SendDlgItemMessage(IDC_PICSRULES_LIST,
  511. LB_DELETESTRING,
  512. (WPARAM) dwSystemToSave-PICSRULES_FIRSTSYSTEMINDEX,
  513. (LPARAM) 0);
  514. SendDlgItemMessage(IDC_PICSRULES_LIST,
  515. LB_INSERTSTRING,
  516. (WPARAM) dwSystemToSave-PICSRULES_FIRSTSYSTEMINDEX,
  517. (LPARAM) lpszName);
  518. }
  519. else
  520. {
  521. char * lpszName=NULL;
  522. g_arrpPICSRulesPRRSPreApply.Append(pPRRS);
  523. //update the listbox
  524. if((pPRRS->m_pPRName)!=NULL)
  525. {
  526. lpszName=pPRRS->m_pPRName->m_etstrRuleName.Get();
  527. }
  528. if(lpszName==NULL)
  529. {
  530. lpszName=pPRRS->m_etstrFile.Get();
  531. }
  532. SendDlgItemMessage(IDC_PICSRULES_LIST,
  533. LB_ADDSTRING,
  534. (WPARAM) 0,
  535. (LPARAM) lpszName);
  536. // if there's now more than one element,
  537. // turn on up and down buttons
  538. if(SendDlgItemMessage( IDC_PICSRULES_LIST,
  539. LB_GETCOUNT, 0, 0) > 1)
  540. {
  541. ::EnableWindow(GetDlgItem( IDC_PICSRULES_UP), TRUE);
  542. ::EnableWindow(GetDlgItem( IDC_PICSRULES_DOWN), TRUE);
  543. }
  544. }
  545. fPICSRulesSaved=TRUE;
  546. MarkChanged();
  547. }
  548. else
  549. {
  550. pPRRS->ReportError(hRes);
  551. delete pPRRS;
  552. pPRRS=NULL;
  553. }
  554. if (!fPICSRulesSaved)
  555. {
  556. if (pPRRS)
  557. {
  558. //we successfully processed the PICSRules, but couldn't
  559. //save them
  560. MyMessageBox(m_hWnd, IDS_PICSRULES_ERRORSAVINGMSG, IDS_PICSRULES_ERRORSAVINGTITLE, MB_OK|MB_ICONERROR);
  561. delete pPRRS;
  562. pPRRS=NULL;
  563. }
  564. }
  565. else
  566. {
  567. //Success! Notify the user.
  568. MyMessageBox(m_hWnd, IDS_PICSRULES_SUCCESSMESSAGE, IDS_PICSRULES_SUCCESSTITLE, MB_OK);
  569. }
  570. }
  571. g_pPRRS=NULL; //done processing the current system, so make sure it
  572. //doesn't point to anything
  573. return 1L;
  574. }
  575. LRESULT CAdvancedDialog::OnSetActive(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  576. {
  577. PRSD * pPRSD = m_pPRSD;
  578. ASSERT( pPRSD );
  579. if ( ! pPRSD )
  580. {
  581. TraceMsg( TF_ERROR, "CAdvancedDialog::OnSetActive() - pPRSD is NULL!" );
  582. return 0L;
  583. }
  584. if(pPRSD->fNewProviders==TRUE)
  585. {
  586. FillBureauList( pPRSD->pPRSI);
  587. }
  588. bHandled = FALSE;
  589. return 0L;
  590. }
  591. LRESULT CAdvancedDialog::OnApply(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  592. {
  593. LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY) pnmh;
  594. /*do apply stuff*/
  595. PRSD * pPRSD = m_pPRSD;
  596. DWORD dwNumExistingSystems,dwCounter;
  597. /*do apply stuff*/
  598. /* Get the text from the rating bureau combo box. */
  599. /* Default for etstrRatingBureau (the URL) will be this text. */
  600. NLS_STR nlsURL;
  601. int i;
  602. const char *p;
  603. if (nlsURL.realloc( ::GetWindowTextLength(GetDlgItem( IDC_3RD_COMBO)) + 1)) {
  604. GetDlgItemText( IDC_3RD_COMBO, nlsURL.Party(), nlsURL.QueryAllocSize());
  605. nlsURL.DonePartying();
  606. p = (char *)nlsURL.QueryPch();
  607. INT_PTR temp = SendDlgItemMessage( IDC_3RD_COMBO, CB_GETCURSEL, 0, 0L);
  608. if (temp != CB_ERR) {
  609. /* Get the text of the selected item in the list. */
  610. UINT cbName = (UINT)SendDlgItemMessage( IDC_3RD_COMBO, CB_GETLBTEXTLEN, temp, 0);
  611. NLS_STR nlsName(cbName+1);
  612. if (nlsName.QueryError())
  613. p = NULL;
  614. else {
  615. /* If the text of the selected item in the list
  616. * is what's in the edit field, then the user
  617. * has selected one of those rating system names.
  618. * The itemdata for the item is the URL.
  619. */
  620. SendDlgItemMessage( IDC_3RD_COMBO, CB_GETLBTEXT, temp, (LPARAM)(LPSTR)nlsName.Party());
  621. nlsName.DonePartying();
  622. if (nlsName == nlsURL)
  623. p = (char *)SendDlgItemMessage( IDC_3RD_COMBO, CB_GETITEMDATA, temp, 0L);
  624. }
  625. }
  626. }
  627. else
  628. {
  629. p = NULL;
  630. }
  631. if (pPRSD->pPRSI->etstrRatingBureau.fIsInit() && (!p ||
  632. strcmpf(pPRSD->pPRSI->etstrRatingBureau.Get(),p)))
  633. {
  634. // check if old bureau is required
  635. for (i = 0; i <pPRSD->pPRSI->arrpPRS.Length(); ++i)
  636. {
  637. if (pPRSD->pPRSI->arrpPRS[i]->etstrRatingBureau.fIsInit() &&
  638. (!strcmpf(pPRSD->pPRSI->etstrRatingBureau.Get(),
  639. pPRSD->pPRSI->arrpPRS[i]->etstrRatingBureau.Get())))
  640. {
  641. if (!(pPRSD->pPRSI->arrpPRS[i]->etbBureauRequired.Get()))
  642. {
  643. break; // Not required. We're done.
  644. }
  645. //We're removing a bureau that's required. Warn user.
  646. char pszBuf[MAXPATHLEN];
  647. char szTemp[MAXPATHLEN];
  648. MLLoadStringA(IDS_NEEDBUREAU, pszBuf, sizeof(pszBuf));
  649. wsprintf(szTemp, pszBuf, pPRSD->pPRSI->arrpPRS[i]->etstrName.Get());
  650. if (MessageBox(szTemp, NULL, MB_YESNO) == IDNO)
  651. {
  652. return PSNRET_INVALID_NOCHANGEPAGE;
  653. }
  654. else
  655. {
  656. break;
  657. }
  658. }
  659. }
  660. }
  661. if (!p || !*p)
  662. {
  663. pPRSD->pPRSI->etstrRatingBureau.Set(NULL);
  664. DeinstallRatingBureauHelper();
  665. }
  666. else
  667. {
  668. pPRSD->pPRSI->etstrRatingBureau.Set((LPSTR)p);
  669. InstallRatingBureauHelper();
  670. }
  671. /* Update the rating helper list to include or not include
  672. * the rating bureau helper.
  673. */
  674. CleanupRatingHelpers();
  675. InitRatingHelpers();
  676. //process PICSRules
  677. PICSRulesGetNumSystems(&dwNumExistingSystems);
  678. for(dwCounter=0;dwCounter<dwNumExistingSystems;dwCounter++)
  679. {
  680. //delete all existing systems from the registry
  681. PICSRulesDeleteSystem(dwCounter+PICSRULES_FIRSTSYSTEMINDEX);
  682. }
  683. g_arrpPRRS.DeleteAll();
  684. CopyArrayPRRSStructures(&g_arrpPRRS,&g_arrpPICSRulesPRRSPreApply);
  685. for(dwCounter=0;dwCounter<(DWORD) (g_arrpPRRS.Length());dwCounter++)
  686. {
  687. g_pPRRS=g_arrpPRRS[dwCounter];
  688. PICSRulesSaveToRegistry(dwCounter+PICSRULES_FIRSTSYSTEMINDEX,&g_arrpPRRS[dwCounter]);
  689. }
  690. PICSRulesSetNumSystems(g_arrpPICSRulesPRRSPreApply.Length());
  691. SHGlobalCounterIncrement(g_HandleGlobalCounter);
  692. if ( ! lpPSHNotify->lParam )
  693. {
  694. // Apply
  695. return PSNRET_NOERROR;
  696. }
  697. // Return 1L for OK or Cancel
  698. return PSNRET_NOERROR;
  699. }
  700. LRESULT CAdvancedDialog::OnReset(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  701. {
  702. return 0L;
  703. }
  704. LRESULT CAdvancedDialog::OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  705. {
  706. SHWinHelpOnDemandWrap((HWND)((LPHELPINFO)lParam)->hItemHandle, ::szHelpFile,
  707. HELP_WM_HELP, (DWORD_PTR)(LPSTR)aIds);
  708. return 0L;
  709. }
  710. LRESULT CAdvancedDialog::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  711. {
  712. SHWinHelpOnDemandWrap((HWND)wParam, ::szHelpFile, HELP_CONTEXTMENU,
  713. (DWORD_PTR)(LPVOID)aIds);
  714. return 0L;
  715. }
  716. void CAdvancedDialog::InstallRatingBureauHelper( void )
  717. {
  718. HKEY hkey;
  719. hkey = CreateRegKeyNT( ::szRATINGHELPERS );
  720. if ( hkey != NULL )
  721. {
  722. CRegKey key;
  723. key.Attach( hkey );
  724. key.SetValue( szRORSGUID, szNULL );
  725. }
  726. else
  727. {
  728. TraceMsg( TF_ERROR, "CAdvancedDialog::InstallRatingBureauHelper() - Failed to create key szRATINGHELPERS='%s'!", szRATINGHELPERS );
  729. }
  730. }
  731. void CAdvancedDialog::DeinstallRatingBureauHelper( void )
  732. {
  733. CRegKey key;
  734. if ( key.Open( HKEY_LOCAL_MACHINE, szRATINGHELPERS ) == ERROR_SUCCESS )
  735. {
  736. key.DeleteValue( szRORSGUID );
  737. }
  738. }
  739. UINT CAdvancedDialog::FillBureauList( PicsRatingSystemInfo *pPRSI )
  740. {
  741. int i;
  742. INT_PTR z;
  743. BOOL fHaveBureau = pPRSI->etstrRatingBureau.fIsInit();
  744. BOOL fSelectedOne = FALSE;
  745. HWND hwndCombo = GetDlgItem( IDC_3RD_COMBO);
  746. LPCSTR pszCurrentBureau;
  747. BOOL fListBureau = FALSE;
  748. NLS_STR nlsURL;
  749. /* Save current selection if at all possible. If an item in the listbox
  750. * is selected, get its item data, which is the rating bureau string.
  751. *
  752. * We remember if it was an item from the list that was selected before;
  753. * that indicates that the bureau belongs to a rating system, and if we
  754. * don't find it in the list after reinitializing, we know that rating
  755. * system has been removed and the bureau is probably useless now.
  756. */
  757. z = SendMessage(hwndCombo, CB_GETCURSEL, 0, 0);
  758. if (z != CB_ERR)
  759. {
  760. pszCurrentBureau = (LPCSTR)SendMessage(hwndCombo, CB_GETITEMDATA, z, 0);
  761. fListBureau = TRUE;
  762. }
  763. else
  764. {
  765. /* No item selected. If there is text in the edit control, preserve
  766. * it; otherwise, try to select the current rating bureau if any.
  767. */
  768. UINT cch = ::GetWindowTextLength(hwndCombo);
  769. if (cch > 0 && nlsURL.realloc(cch + 1)) {
  770. ::GetWindowText(hwndCombo, nlsURL.Party(), nlsURL.QueryAllocSize());
  771. nlsURL.DonePartying();
  772. pszCurrentBureau = nlsURL.QueryPch();
  773. }
  774. else
  775. {
  776. pszCurrentBureau = fHaveBureau ? pPRSI->etstrRatingBureau.Get() : szNULL;
  777. }
  778. }
  779. SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);
  780. for (i = 0; i < pPRSI->arrpPRS.Length(); ++i)
  781. {
  782. PicsRatingSystem *prs = pPRSI->arrpPRS[i];
  783. if (prs->etstrRatingBureau.fIsInit())
  784. {
  785. z = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)prs->etstrName.Get());
  786. SendMessage(hwndCombo, CB_SETITEMDATA, z,
  787. (LPARAM)prs->etstrRatingBureau.Get());
  788. if (!fSelectedOne)
  789. {
  790. if (!strcmpf(pszCurrentBureau, prs->etstrRatingBureau.Get()))
  791. {
  792. SendMessage(hwndCombo, CB_SETCURSEL, z,0);
  793. fSelectedOne = TRUE;
  794. }
  795. }
  796. }
  797. }
  798. NLS_STR nlsNone(MAX_RES_STR_LEN);
  799. if (nlsNone.LoadString(IDS_NO_BUREAU) != ERROR_SUCCESS)
  800. nlsNone = NULL;
  801. z = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)nlsNone.QueryPch());
  802. SendMessage(hwndCombo, CB_SETITEMDATA, z, 0L);
  803. if (!fSelectedOne)
  804. {
  805. if (!fListBureau && *pszCurrentBureau != '\0')
  806. ::SetWindowText(hwndCombo, pszCurrentBureau);
  807. else
  808. SendMessage(hwndCombo, CB_SETCURSEL, z, 0L);
  809. }
  810. return 0;
  811. }
  812. HRESULT CAdvancedDialog::CopySubPolicyExpression(PICSRulesPolicyExpression * pPRSubPolicyExpression,
  813. PICSRulesPolicyExpression * pPRSubPolicyExpressionToCopy,
  814. PICSRulesRatingSystem * pPRRSLocal,
  815. PICSRulesPolicy * pPRPolicy)
  816. {
  817. BOOL fFlag;
  818. fFlag=pPRSubPolicyExpressionToCopy->m_prYesNoUseEmbedded.GetYesNo();
  819. pPRSubPolicyExpression->m_prYesNoUseEmbedded.Set(&fFlag);
  820. pPRSubPolicyExpression->m_etstrServiceName.Set(pPRSubPolicyExpressionToCopy->m_etstrServiceName.Get());
  821. pPRSubPolicyExpression->m_etstrCategoryName.Set(pPRSubPolicyExpressionToCopy->m_etstrCategoryName.Get());
  822. pPRSubPolicyExpression->m_etstrFullServiceName.Set(pPRSubPolicyExpressionToCopy->m_etstrFullServiceName.Get());
  823. pPRSubPolicyExpression->m_etnValue.Set(pPRSubPolicyExpressionToCopy->m_etnValue.Get());
  824. pPRSubPolicyExpression->m_PROPolicyOperator=pPRSubPolicyExpressionToCopy->m_PROPolicyOperator;
  825. pPRSubPolicyExpression->m_PRPEPolicyEmbedded=pPRSubPolicyExpressionToCopy->m_PRPEPolicyEmbedded;
  826. if(pPRSubPolicyExpressionToCopy->m_pPRPolicyExpressionLeft!=NULL)
  827. {
  828. PICSRulesPolicyExpression * pPRSubPolicyExpression2,* pPRSubPolicyExpressionToCopy2;
  829. pPRSubPolicyExpression2=new PICSRulesPolicyExpression;
  830. if(pPRSubPolicyExpression2==NULL)
  831. {
  832. PICSRulesOutOfMemory();
  833. delete pPRRSLocal;
  834. pPRRSLocal = NULL;
  835. delete pPRPolicy;
  836. pPRPolicy = NULL;
  837. return(E_OUTOFMEMORY);
  838. }
  839. pPRSubPolicyExpressionToCopy2=pPRSubPolicyExpressionToCopy->m_pPRPolicyExpressionLeft;
  840. if(FAILED(CopySubPolicyExpression(pPRSubPolicyExpression2,pPRSubPolicyExpressionToCopy2,pPRRSLocal,pPRPolicy)))
  841. {
  842. return(E_OUTOFMEMORY);
  843. }
  844. pPRSubPolicyExpression->m_pPRPolicyExpressionLeft=pPRSubPolicyExpression2;
  845. }
  846. if(pPRSubPolicyExpressionToCopy->m_pPRPolicyExpressionRight!=NULL)
  847. {
  848. PICSRulesPolicyExpression * pPRSubPolicyExpression2,* pPRSubPolicyExpressionToCopy2;
  849. pPRSubPolicyExpression2=new PICSRulesPolicyExpression;
  850. if(pPRSubPolicyExpression2==NULL)
  851. {
  852. PICSRulesOutOfMemory();
  853. delete pPRRSLocal;
  854. pPRRSLocal = NULL;
  855. delete pPRPolicy;
  856. pPRPolicy = NULL;
  857. return(E_OUTOFMEMORY);
  858. }
  859. pPRSubPolicyExpressionToCopy2=pPRSubPolicyExpressionToCopy->m_pPRPolicyExpressionRight;
  860. if(FAILED(CopySubPolicyExpression(pPRSubPolicyExpression2,pPRSubPolicyExpressionToCopy2,pPRRSLocal,pPRPolicy)))
  861. {
  862. return(E_OUTOFMEMORY);
  863. }
  864. pPRSubPolicyExpression->m_pPRPolicyExpressionRight=pPRSubPolicyExpression2;
  865. }
  866. return(NOERROR);
  867. }
  868. HRESULT CAdvancedDialog::CopyArrayPRRSStructures(array<PICSRulesRatingSystem*> * parrpPRRSDest,array<PICSRulesRatingSystem*> * parrpPRRSSource)
  869. {
  870. DWORD dwCounter;
  871. PICSRulesRatingSystem * pPRRSLocal,* pPRRSBeingCopied;
  872. PICSRulesPolicy * pPRPolicy,* pPRPolicyBeingCopied;
  873. PICSRulesPolicyExpression * pPRPolicyExpression,* pPRPolicyExpressionBeingCopied;
  874. PICSRulesServiceInfo * pPRServiceInfo,* pPRServiceInfoBeingCopied;
  875. PICSRulesOptExtension * pPROptExtension,* pPROptExtensionBeingCopied;
  876. PICSRulesReqExtension * pPRReqExtension,* pPRReqExtensionBeingCopied;
  877. PICSRulesName * pPRName,* pPRNameBeingCopied;
  878. PICSRulesSource * pPRSource,* pPRSourceBeingCopied;
  879. PICSRulesByURL * pPRByURL,* pPRByURLToCopy;
  880. PICSRulesByURLExpression * pPRByURLExpression,* pPRByURLExpressionToCopy;
  881. if(parrpPRRSDest->Length()>0)
  882. {
  883. parrpPRRSDest->DeleteAll();
  884. }
  885. for(dwCounter=0;dwCounter<(DWORD) (parrpPRRSSource->Length());dwCounter++)
  886. {
  887. pPRRSLocal=new PICSRulesRatingSystem;
  888. if(pPRRSLocal==NULL)
  889. {
  890. PICSRulesOutOfMemory();
  891. return(E_OUTOFMEMORY);
  892. }
  893. pPRRSBeingCopied=(*parrpPRRSSource)[dwCounter];
  894. pPRRSLocal->m_etstrFile.Set(pPRRSBeingCopied->m_etstrFile.Get());
  895. pPRRSLocal->m_etnPRVerMajor.Set(pPRRSBeingCopied->m_etnPRVerMajor.Get());
  896. pPRRSLocal->m_etnPRVerMinor.Set(pPRRSBeingCopied->m_etnPRVerMinor.Get());
  897. pPRRSLocal->m_dwFlags=pPRRSBeingCopied->m_dwFlags;
  898. pPRRSLocal->m_nErrLine=pPRRSBeingCopied->m_nErrLine;
  899. if((pPRRSBeingCopied->m_pPRName)!=NULL)
  900. {
  901. pPRName=new PICSRulesName;
  902. if(pPRName==NULL)
  903. {
  904. PICSRulesOutOfMemory();
  905. delete pPRRSLocal;
  906. pPRRSLocal = NULL;
  907. return(E_OUTOFMEMORY);
  908. }
  909. pPRNameBeingCopied=pPRRSBeingCopied->m_pPRName;
  910. pPRName->m_etstrRuleName.Set(pPRNameBeingCopied->m_etstrRuleName.Get());
  911. pPRName->m_etstrDescription.Set(pPRNameBeingCopied->m_etstrDescription.Get());
  912. pPRRSLocal->m_pPRName=pPRName;
  913. }
  914. else
  915. {
  916. pPRRSLocal->m_pPRName=NULL;
  917. }
  918. if((pPRRSBeingCopied->m_pPRSource)!=NULL)
  919. {
  920. pPRSource=new PICSRulesSource;
  921. if(pPRSource==NULL)
  922. {
  923. PICSRulesOutOfMemory();
  924. delete pPRRSLocal;
  925. pPRRSLocal = NULL;
  926. return(E_OUTOFMEMORY);
  927. }
  928. pPRSourceBeingCopied=pPRRSBeingCopied->m_pPRSource;
  929. pPRSource->m_prURLSourceURL.Set(pPRSourceBeingCopied->m_prURLSourceURL.Get());
  930. pPRSource->m_etstrCreationTool.Set(pPRSourceBeingCopied->m_etstrCreationTool.Get());
  931. pPRSource->m_prEmailAuthor.Set(pPRSourceBeingCopied->m_prEmailAuthor.Get());
  932. pPRSource->m_prDateLastModified.Set(pPRSourceBeingCopied->m_prDateLastModified.Get());
  933. pPRRSLocal->m_pPRSource=pPRSource;
  934. }
  935. else
  936. {
  937. pPRRSLocal->m_pPRSource=NULL;
  938. }
  939. if(pPRRSBeingCopied->m_arrpPRPolicy.Length()>0)
  940. {
  941. DWORD dwSubCounter;
  942. for(dwSubCounter=0;dwSubCounter<(DWORD) (pPRRSBeingCopied->m_arrpPRPolicy.Length());dwSubCounter++)
  943. {
  944. DWORD dwPolicyExpressionSubCounter;
  945. pPRPolicy=new PICSRulesPolicy;
  946. pPRPolicyBeingCopied=pPRRSBeingCopied->m_arrpPRPolicy[dwSubCounter];
  947. if(pPRPolicy==NULL)
  948. {
  949. PICSRulesOutOfMemory();
  950. delete pPRRSLocal;
  951. pPRRSLocal = NULL;
  952. return(E_OUTOFMEMORY);
  953. }
  954. pPRPolicy->m_etstrExplanation.Set(pPRPolicyBeingCopied->m_etstrExplanation.Get());
  955. pPRPolicy->m_PRPolicyAttribute=pPRPolicyBeingCopied->m_PRPolicyAttribute;
  956. pPRByURLToCopy=NULL;
  957. pPRPolicyExpressionBeingCopied=NULL;
  958. switch(pPRPolicy->m_PRPolicyAttribute)
  959. {
  960. case PR_POLICY_ACCEPTBYURL:
  961. {
  962. pPRByURLToCopy=pPRPolicyBeingCopied->m_pPRAcceptByURL;
  963. pPRByURL=new PICSRulesByURL;
  964. if(pPRByURL==NULL)
  965. {
  966. PICSRulesOutOfMemory();
  967. delete pPRRSLocal;
  968. pPRRSLocal = NULL;
  969. delete pPRPolicy;
  970. pPRPolicy = NULL;
  971. return(E_OUTOFMEMORY);
  972. }
  973. pPRPolicy->m_pPRAcceptByURL=pPRByURL;
  974. break;
  975. }
  976. case PR_POLICY_REJECTBYURL:
  977. {
  978. pPRByURLToCopy=pPRPolicyBeingCopied->m_pPRRejectByURL;
  979. pPRByURL=new PICSRulesByURL;
  980. if(pPRByURL==NULL)
  981. {
  982. PICSRulesOutOfMemory();
  983. delete pPRRSLocal;
  984. pPRRSLocal = NULL;
  985. delete pPRPolicy;
  986. pPRPolicy = NULL;
  987. return(E_OUTOFMEMORY);
  988. }
  989. pPRPolicy->m_pPRRejectByURL=pPRByURL;
  990. break;
  991. }
  992. case PR_POLICY_REJECTIF:
  993. {
  994. pPRPolicyExpressionBeingCopied=pPRPolicyBeingCopied->m_pPRRejectIf;
  995. pPRPolicyExpression=new PICSRulesPolicyExpression;
  996. if(pPRPolicyExpression==NULL)
  997. {
  998. PICSRulesOutOfMemory();
  999. delete pPRRSLocal;
  1000. pPRRSLocal = NULL;
  1001. delete pPRPolicy;
  1002. pPRPolicy = NULL;
  1003. return(E_OUTOFMEMORY);
  1004. }
  1005. pPRPolicy->m_pPRRejectIf=pPRPolicyExpression;
  1006. break;
  1007. }
  1008. case PR_POLICY_ACCEPTIF:
  1009. {
  1010. pPRPolicyExpressionBeingCopied=pPRPolicyBeingCopied->m_pPRAcceptIf;
  1011. pPRPolicyExpression=new PICSRulesPolicyExpression;
  1012. if(pPRPolicyExpression==NULL)
  1013. {
  1014. PICSRulesOutOfMemory();
  1015. delete pPRRSLocal;
  1016. pPRRSLocal = NULL;
  1017. delete pPRPolicy;
  1018. pPRPolicy = NULL;
  1019. return(E_OUTOFMEMORY);
  1020. }
  1021. pPRPolicy->m_pPRAcceptIf=pPRPolicyExpression;
  1022. break;
  1023. }
  1024. case PR_POLICY_REJECTUNLESS:
  1025. {
  1026. pPRPolicyExpressionBeingCopied=pPRPolicyBeingCopied->m_pPRRejectUnless;
  1027. pPRPolicyExpression=new PICSRulesPolicyExpression;
  1028. if(pPRPolicyExpression==NULL)
  1029. {
  1030. PICSRulesOutOfMemory();
  1031. delete pPRRSLocal;
  1032. pPRRSLocal = NULL;
  1033. delete pPRPolicy;
  1034. pPRPolicy = NULL;
  1035. return(E_OUTOFMEMORY);
  1036. }
  1037. pPRPolicy->m_pPRRejectUnless=pPRPolicyExpression;
  1038. break;
  1039. }
  1040. case PR_POLICY_ACCEPTUNLESS:
  1041. {
  1042. pPRPolicyExpressionBeingCopied=pPRPolicyBeingCopied->m_pPRAcceptUnless;
  1043. pPRPolicyExpression=new PICSRulesPolicyExpression;
  1044. if(pPRPolicyExpression==NULL)
  1045. {
  1046. PICSRulesOutOfMemory();
  1047. delete pPRRSLocal;
  1048. pPRRSLocal = NULL;
  1049. delete pPRPolicy;
  1050. pPRPolicy = NULL;
  1051. return(E_OUTOFMEMORY);
  1052. }
  1053. pPRPolicy->m_pPRAcceptUnless=pPRPolicyExpression;
  1054. break;
  1055. }
  1056. }
  1057. if(pPRByURLToCopy!=NULL)
  1058. {
  1059. for(dwPolicyExpressionSubCounter=0;
  1060. dwPolicyExpressionSubCounter<(DWORD) (pPRByURLToCopy->m_arrpPRByURL.Length());
  1061. dwPolicyExpressionSubCounter++)
  1062. {
  1063. pPRByURLExpression=new PICSRulesByURLExpression;
  1064. if(pPRByURLExpression==NULL)
  1065. {
  1066. PICSRulesOutOfMemory();
  1067. delete pPRRSLocal;
  1068. pPRRSLocal = NULL;
  1069. delete pPRPolicy;
  1070. pPRPolicy = NULL;
  1071. return(E_OUTOFMEMORY);
  1072. }
  1073. pPRByURLExpressionToCopy=pPRByURLToCopy->m_arrpPRByURL[dwPolicyExpressionSubCounter];
  1074. pPRByURLExpression->m_fInternetPattern=pPRByURLExpressionToCopy->m_fInternetPattern;
  1075. pPRByURLExpression->m_bNonWild=pPRByURLExpressionToCopy->m_bNonWild;
  1076. pPRByURLExpression->m_bSpecified=pPRByURLExpressionToCopy->m_bSpecified;
  1077. pPRByURLExpression->m_etstrScheme.Set(pPRByURLExpressionToCopy->m_etstrScheme.Get());
  1078. pPRByURLExpression->m_etstrUser.Set(pPRByURLExpressionToCopy->m_etstrUser.Get());
  1079. pPRByURLExpression->m_etstrHost.Set(pPRByURLExpressionToCopy->m_etstrHost.Get());
  1080. pPRByURLExpression->m_etstrPort.Set(pPRByURLExpressionToCopy->m_etstrPort.Get());
  1081. pPRByURLExpression->m_etstrPath.Set(pPRByURLExpressionToCopy->m_etstrPath.Get());
  1082. pPRByURLExpression->m_etstrURL.Set(pPRByURLExpressionToCopy->m_etstrURL.Get());
  1083. pPRByURL->m_arrpPRByURL.Append(pPRByURLExpression);
  1084. }
  1085. pPRRSLocal->m_arrpPRPolicy.Append(pPRPolicy);
  1086. }
  1087. if(pPRPolicyExpressionBeingCopied!=NULL)
  1088. {
  1089. BOOL fFlag;
  1090. fFlag=pPRPolicyExpressionBeingCopied->m_prYesNoUseEmbedded.GetYesNo();
  1091. pPRPolicyExpression->m_prYesNoUseEmbedded.Set(&fFlag);
  1092. pPRPolicyExpression->m_etstrServiceName.Set(pPRPolicyExpressionBeingCopied->m_etstrServiceName.Get());
  1093. pPRPolicyExpression->m_etstrCategoryName.Set(pPRPolicyExpressionBeingCopied->m_etstrCategoryName.Get());
  1094. pPRPolicyExpression->m_etstrFullServiceName.Set(pPRPolicyExpressionBeingCopied->m_etstrFullServiceName.Get());
  1095. pPRPolicyExpression->m_etnValue.Set(pPRPolicyExpressionBeingCopied->m_etnValue.Get());
  1096. pPRPolicyExpression->m_PROPolicyOperator=pPRPolicyExpressionBeingCopied->m_PROPolicyOperator;
  1097. pPRPolicyExpression->m_PRPEPolicyEmbedded=pPRPolicyExpressionBeingCopied->m_PRPEPolicyEmbedded;
  1098. if(pPRPolicyExpressionBeingCopied->m_pPRPolicyExpressionLeft!=NULL)
  1099. {
  1100. PICSRulesPolicyExpression * pPRSubPolicyExpression,* pPRSubPolicyExpressionToCopy;
  1101. pPRSubPolicyExpression=new PICSRulesPolicyExpression;
  1102. if(pPRSubPolicyExpression==NULL)
  1103. {
  1104. PICSRulesOutOfMemory();
  1105. delete pPRRSLocal;
  1106. pPRRSLocal = NULL;
  1107. delete pPRPolicy;
  1108. pPRPolicy = NULL;
  1109. return(E_OUTOFMEMORY);
  1110. }
  1111. pPRSubPolicyExpressionToCopy=pPRPolicyExpressionBeingCopied->m_pPRPolicyExpressionLeft;
  1112. if(FAILED(CopySubPolicyExpression(pPRSubPolicyExpression,pPRSubPolicyExpressionToCopy,pPRRSLocal,pPRPolicy)))
  1113. {
  1114. return(E_OUTOFMEMORY);
  1115. }
  1116. pPRPolicyExpression->m_pPRPolicyExpressionLeft=pPRSubPolicyExpression;
  1117. }
  1118. if(pPRPolicyExpressionBeingCopied->m_pPRPolicyExpressionRight!=NULL)
  1119. {
  1120. PICSRulesPolicyExpression * pPRSubPolicyExpression,* pPRSubPolicyExpressionToCopy;
  1121. pPRSubPolicyExpression=new PICSRulesPolicyExpression;
  1122. if(pPRSubPolicyExpression==NULL)
  1123. {
  1124. PICSRulesOutOfMemory();
  1125. delete pPRRSLocal;
  1126. pPRRSLocal = NULL;
  1127. delete pPRPolicy;
  1128. pPRPolicy = NULL;
  1129. return(E_OUTOFMEMORY);
  1130. }
  1131. pPRSubPolicyExpressionToCopy=pPRPolicyExpressionBeingCopied->m_pPRPolicyExpressionRight;
  1132. if(FAILED(CopySubPolicyExpression(pPRSubPolicyExpression,pPRSubPolicyExpressionToCopy,pPRRSLocal,pPRPolicy)))
  1133. {
  1134. return(E_OUTOFMEMORY);
  1135. }
  1136. pPRPolicyExpression->m_pPRPolicyExpressionRight=pPRSubPolicyExpression;
  1137. }
  1138. pPRRSLocal->m_arrpPRPolicy.Append(pPRPolicy);
  1139. }
  1140. }
  1141. }
  1142. if(pPRRSBeingCopied->m_arrpPRServiceInfo.Length()>0)
  1143. {
  1144. DWORD dwSubCounter;
  1145. for(dwSubCounter=0;dwSubCounter<(DWORD) (pPRRSBeingCopied->m_arrpPRServiceInfo.Length());dwSubCounter++)
  1146. {
  1147. BOOL fFlag;
  1148. pPRServiceInfo=new PICSRulesServiceInfo;
  1149. if(pPRServiceInfo==NULL)
  1150. {
  1151. PICSRulesOutOfMemory();
  1152. delete pPRRSLocal;
  1153. pPRRSLocal = NULL;
  1154. return(E_OUTOFMEMORY);
  1155. }
  1156. pPRServiceInfoBeingCopied=pPRRSBeingCopied->m_arrpPRServiceInfo[dwSubCounter];
  1157. pPRServiceInfo->m_prURLName.Set(pPRServiceInfoBeingCopied->m_prURLName.Get());
  1158. pPRServiceInfo->m_prURLBureauURL.Set(pPRServiceInfoBeingCopied->m_prURLBureauURL.Get());
  1159. pPRServiceInfo->m_etstrShortName.Set(pPRServiceInfoBeingCopied->m_etstrShortName.Get());
  1160. pPRServiceInfo->m_etstrRatfile.Set(pPRServiceInfoBeingCopied->m_etstrRatfile.Get());
  1161. fFlag=pPRServiceInfoBeingCopied->m_prYesNoUseEmbedded.GetYesNo();
  1162. pPRServiceInfo->m_prYesNoUseEmbedded.Set(&fFlag);
  1163. fFlag=pPRServiceInfoBeingCopied->m_prPassFailBureauUnavailable.GetPassFail();
  1164. pPRServiceInfo->m_prPassFailBureauUnavailable.Set(&fFlag);
  1165. pPRRSLocal->m_arrpPRServiceInfo.Append(pPRServiceInfo);
  1166. }
  1167. }
  1168. if(pPRRSBeingCopied->m_arrpPROptExtension.Length()>0)
  1169. {
  1170. DWORD dwSubCounter;
  1171. for(dwSubCounter=0;dwSubCounter<(DWORD) (pPRRSBeingCopied->m_arrpPROptExtension.Length());dwSubCounter++)
  1172. {
  1173. pPROptExtension=new PICSRulesOptExtension;
  1174. if(pPROptExtension==NULL)
  1175. {
  1176. PICSRulesOutOfMemory();
  1177. delete pPRRSLocal;
  1178. pPRRSLocal = NULL;
  1179. return(E_OUTOFMEMORY);
  1180. }
  1181. pPROptExtensionBeingCopied=pPRRSBeingCopied->m_arrpPROptExtension[dwSubCounter];
  1182. pPROptExtension->m_prURLExtensionName.Set(pPROptExtensionBeingCopied->m_prURLExtensionName.Get());
  1183. pPROptExtension->m_etstrShortName.Set(pPROptExtensionBeingCopied->m_etstrShortName.Get());
  1184. pPRRSLocal->m_arrpPROptExtension.Append(pPROptExtension);
  1185. }
  1186. }
  1187. if(pPRRSBeingCopied->m_arrpPRReqExtension.Length()>0)
  1188. {
  1189. DWORD dwSubCounter;
  1190. for(dwSubCounter=0;dwSubCounter<(DWORD) (pPRRSBeingCopied->m_arrpPRReqExtension.Length());dwSubCounter++)
  1191. {
  1192. pPRReqExtension=new PICSRulesReqExtension;
  1193. if(pPRReqExtension==NULL)
  1194. {
  1195. PICSRulesOutOfMemory();
  1196. delete pPRRSLocal;
  1197. pPRRSLocal = NULL;
  1198. return(E_OUTOFMEMORY);
  1199. }
  1200. pPRReqExtensionBeingCopied=pPRRSBeingCopied->m_arrpPRReqExtension[dwSubCounter];
  1201. pPRReqExtension->m_prURLExtensionName.Set(pPRReqExtensionBeingCopied->m_prURLExtensionName.Get());
  1202. pPRReqExtension->m_etstrShortName.Set(pPRReqExtensionBeingCopied->m_etstrShortName.Get());
  1203. pPRRSLocal->m_arrpPRReqExtension.Append(pPRReqExtension);
  1204. }
  1205. }
  1206. parrpPRRSDest->Append(pPRRSLocal);
  1207. }
  1208. return(NOERROR);
  1209. }