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.

1587 lines
52 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. CHAR *pszUrl = nlsURL.Party();
  605. if (pszUrl) {
  606. GetDlgItemText( IDC_3RD_COMBO, pszUrl, nlsURL.QueryAllocSize());
  607. nlsURL.DonePartying();
  608. p = (char *)nlsURL.QueryPch();
  609. INT_PTR temp = SendDlgItemMessage( IDC_3RD_COMBO, CB_GETCURSEL, 0, 0L);
  610. if (temp != CB_ERR) {
  611. /* Get the text of the selected item in the list. */
  612. UINT cbName = (UINT)SendDlgItemMessage( IDC_3RD_COMBO, CB_GETLBTEXTLEN, temp, 0);
  613. NLS_STR nlsName(cbName+1);
  614. if (nlsName.QueryError())
  615. p = NULL;
  616. else {
  617. /* If the text of the selected item in the list
  618. * is what's in the edit field, then the user
  619. * has selected one of those rating system names.
  620. * The itemdata for the item is the URL.
  621. */
  622. SendDlgItemMessage( IDC_3RD_COMBO, CB_GETLBTEXT, temp, (LPARAM)(LPSTR)nlsName.Party());
  623. nlsName.DonePartying();
  624. if (nlsName == nlsURL)
  625. p = (char *)SendDlgItemMessage( IDC_3RD_COMBO, CB_GETITEMDATA, temp, 0L);
  626. }
  627. }
  628. }
  629. else
  630. {
  631. p = NULL;
  632. }
  633. }
  634. else
  635. {
  636. p = NULL;
  637. }
  638. if (pPRSD->pPRSI->etstrRatingBureau.fIsInit() && (!p ||
  639. strcmpf(pPRSD->pPRSI->etstrRatingBureau.Get(),p)))
  640. {
  641. // check if old bureau is required
  642. for (i = 0; i <pPRSD->pPRSI->arrpPRS.Length(); ++i)
  643. {
  644. if (pPRSD->pPRSI->arrpPRS[i]->etstrRatingBureau.fIsInit() &&
  645. (!strcmpf(pPRSD->pPRSI->etstrRatingBureau.Get(),
  646. pPRSD->pPRSI->arrpPRS[i]->etstrRatingBureau.Get())))
  647. {
  648. if (!(pPRSD->pPRSI->arrpPRS[i]->etbBureauRequired.Get()))
  649. {
  650. break; // Not required. We're done.
  651. }
  652. //We're removing a bureau that's required. Warn user.
  653. char pszBuf[MAXPATHLEN];
  654. char szTemp[MAXPATHLEN];
  655. MLLoadStringA(IDS_NEEDBUREAU, pszBuf, sizeof(pszBuf));
  656. wsprintf(szTemp, pszBuf, pPRSD->pPRSI->arrpPRS[i]->etstrName.Get());
  657. if (MessageBox(szTemp, NULL, MB_YESNO) == IDNO)
  658. {
  659. return PSNRET_INVALID_NOCHANGEPAGE;
  660. }
  661. else
  662. {
  663. break;
  664. }
  665. }
  666. }
  667. }
  668. if (!p || !*p)
  669. {
  670. pPRSD->pPRSI->etstrRatingBureau.Set(NULL);
  671. DeinstallRatingBureauHelper();
  672. }
  673. else
  674. {
  675. pPRSD->pPRSI->etstrRatingBureau.Set((LPSTR)p);
  676. InstallRatingBureauHelper();
  677. }
  678. /* Update the rating helper list to include or not include
  679. * the rating bureau helper.
  680. */
  681. CleanupRatingHelpers();
  682. InitRatingHelpers();
  683. //process PICSRules
  684. PICSRulesGetNumSystems(&dwNumExistingSystems);
  685. for(dwCounter=0;dwCounter<dwNumExistingSystems;dwCounter++)
  686. {
  687. //delete all existing systems from the registry
  688. PICSRulesDeleteSystem(dwCounter+PICSRULES_FIRSTSYSTEMINDEX);
  689. }
  690. g_arrpPRRS.DeleteAll();
  691. CopyArrayPRRSStructures(&g_arrpPRRS,&g_arrpPICSRulesPRRSPreApply);
  692. for(dwCounter=0;dwCounter<(DWORD) (g_arrpPRRS.Length());dwCounter++)
  693. {
  694. g_pPRRS=g_arrpPRRS[dwCounter];
  695. PICSRulesSaveToRegistry(dwCounter+PICSRULES_FIRSTSYSTEMINDEX,&g_arrpPRRS[dwCounter]);
  696. }
  697. PICSRulesSetNumSystems(g_arrpPICSRulesPRRSPreApply.Length());
  698. SHGlobalCounterIncrement(g_HandleGlobalCounter);
  699. if ( ! lpPSHNotify->lParam )
  700. {
  701. // Apply
  702. return PSNRET_NOERROR;
  703. }
  704. // Return 1L for OK or Cancel
  705. return PSNRET_NOERROR;
  706. }
  707. LRESULT CAdvancedDialog::OnReset(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  708. {
  709. return 0L;
  710. }
  711. LRESULT CAdvancedDialog::OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  712. {
  713. SHWinHelpOnDemandWrap((HWND)((LPHELPINFO)lParam)->hItemHandle, ::szHelpFile,
  714. HELP_WM_HELP, (DWORD_PTR)(LPSTR)aIds);
  715. return 0L;
  716. }
  717. LRESULT CAdvancedDialog::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  718. {
  719. SHWinHelpOnDemandWrap((HWND)wParam, ::szHelpFile, HELP_CONTEXTMENU,
  720. (DWORD_PTR)(LPVOID)aIds);
  721. return 0L;
  722. }
  723. void CAdvancedDialog::InstallRatingBureauHelper( void )
  724. {
  725. HKEY hkey;
  726. hkey = CreateRegKeyNT( ::szRATINGHELPERS );
  727. if ( hkey != NULL )
  728. {
  729. CRegKey key;
  730. key.Attach( hkey );
  731. key.SetValue( szRORSGUID, szNULL );
  732. }
  733. else
  734. {
  735. TraceMsg( TF_ERROR, "CAdvancedDialog::InstallRatingBureauHelper() - Failed to create key szRATINGHELPERS='%s'!", szRATINGHELPERS );
  736. }
  737. }
  738. void CAdvancedDialog::DeinstallRatingBureauHelper( void )
  739. {
  740. CRegKey key;
  741. if ( key.Open( HKEY_LOCAL_MACHINE, szRATINGHELPERS ) == ERROR_SUCCESS )
  742. {
  743. key.DeleteValue( szRORSGUID );
  744. }
  745. }
  746. UINT CAdvancedDialog::FillBureauList( PicsRatingSystemInfo *pPRSI )
  747. {
  748. int i;
  749. INT_PTR z;
  750. BOOL fHaveBureau = pPRSI->etstrRatingBureau.fIsInit();
  751. BOOL fSelectedOne = FALSE;
  752. HWND hwndCombo = GetDlgItem( IDC_3RD_COMBO);
  753. LPCSTR pszCurrentBureau;
  754. BOOL fListBureau = FALSE;
  755. NLS_STR nlsURL;
  756. /* Save current selection if at all possible. If an item in the listbox
  757. * is selected, get its item data, which is the rating bureau string.
  758. *
  759. * We remember if it was an item from the list that was selected before;
  760. * that indicates that the bureau belongs to a rating system, and if we
  761. * don't find it in the list after reinitializing, we know that rating
  762. * system has been removed and the bureau is probably useless now.
  763. */
  764. z = SendMessage(hwndCombo, CB_GETCURSEL, 0, 0);
  765. if (z != CB_ERR)
  766. {
  767. pszCurrentBureau = (LPCSTR)SendMessage(hwndCombo, CB_GETITEMDATA, z, 0);
  768. fListBureau = TRUE;
  769. }
  770. else
  771. {
  772. /* No item selected. If there is text in the edit control, preserve
  773. * it; otherwise, try to select the current rating bureau if any.
  774. */
  775. UINT cch = ::GetWindowTextLength(hwndCombo);
  776. if (cch > 0 && nlsURL.realloc(cch + 1)) {
  777. ::GetWindowText(hwndCombo, nlsURL.Party(), nlsURL.QueryAllocSize());
  778. nlsURL.DonePartying();
  779. pszCurrentBureau = nlsURL.QueryPch();
  780. }
  781. else
  782. {
  783. pszCurrentBureau = fHaveBureau ? pPRSI->etstrRatingBureau.Get() : szNULL;
  784. }
  785. }
  786. SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);
  787. for (i = 0; i < pPRSI->arrpPRS.Length(); ++i)
  788. {
  789. PicsRatingSystem *prs = pPRSI->arrpPRS[i];
  790. if (prs->etstrRatingBureau.fIsInit())
  791. {
  792. z = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)prs->etstrName.Get());
  793. SendMessage(hwndCombo, CB_SETITEMDATA, z,
  794. (LPARAM)prs->etstrRatingBureau.Get());
  795. if (!fSelectedOne)
  796. {
  797. if (!strcmpf(pszCurrentBureau, prs->etstrRatingBureau.Get()))
  798. {
  799. SendMessage(hwndCombo, CB_SETCURSEL, z,0);
  800. fSelectedOne = TRUE;
  801. }
  802. }
  803. }
  804. }
  805. NLS_STR nlsNone(MAX_RES_STR_LEN);
  806. if (nlsNone.LoadString(IDS_NO_BUREAU) != ERROR_SUCCESS)
  807. nlsNone = NULL;
  808. z = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)nlsNone.QueryPch());
  809. SendMessage(hwndCombo, CB_SETITEMDATA, z, 0L);
  810. if (!fSelectedOne)
  811. {
  812. if (!fListBureau && *pszCurrentBureau != '\0')
  813. ::SetWindowText(hwndCombo, pszCurrentBureau);
  814. else
  815. SendMessage(hwndCombo, CB_SETCURSEL, z, 0L);
  816. }
  817. return 0;
  818. }
  819. HRESULT CAdvancedDialog::CopySubPolicyExpression(PICSRulesPolicyExpression * pPRSubPolicyExpression,
  820. PICSRulesPolicyExpression * pPRSubPolicyExpressionToCopy,
  821. PICSRulesRatingSystem * pPRRSLocal,
  822. PICSRulesPolicy * pPRPolicy)
  823. {
  824. BOOL fFlag;
  825. fFlag=pPRSubPolicyExpressionToCopy->m_prYesNoUseEmbedded.GetYesNo();
  826. pPRSubPolicyExpression->m_prYesNoUseEmbedded.Set(&fFlag);
  827. pPRSubPolicyExpression->m_etstrServiceName.Set(pPRSubPolicyExpressionToCopy->m_etstrServiceName.Get());
  828. pPRSubPolicyExpression->m_etstrCategoryName.Set(pPRSubPolicyExpressionToCopy->m_etstrCategoryName.Get());
  829. pPRSubPolicyExpression->m_etstrFullServiceName.Set(pPRSubPolicyExpressionToCopy->m_etstrFullServiceName.Get());
  830. pPRSubPolicyExpression->m_etnValue.Set(pPRSubPolicyExpressionToCopy->m_etnValue.Get());
  831. pPRSubPolicyExpression->m_PROPolicyOperator=pPRSubPolicyExpressionToCopy->m_PROPolicyOperator;
  832. pPRSubPolicyExpression->m_PRPEPolicyEmbedded=pPRSubPolicyExpressionToCopy->m_PRPEPolicyEmbedded;
  833. if(pPRSubPolicyExpressionToCopy->m_pPRPolicyExpressionLeft!=NULL)
  834. {
  835. PICSRulesPolicyExpression * pPRSubPolicyExpression2,* pPRSubPolicyExpressionToCopy2;
  836. pPRSubPolicyExpression2=new PICSRulesPolicyExpression;
  837. if(pPRSubPolicyExpression2==NULL)
  838. {
  839. PICSRulesOutOfMemory();
  840. delete pPRRSLocal;
  841. pPRRSLocal = NULL;
  842. delete pPRPolicy;
  843. pPRPolicy = NULL;
  844. return(E_OUTOFMEMORY);
  845. }
  846. pPRSubPolicyExpressionToCopy2=pPRSubPolicyExpressionToCopy->m_pPRPolicyExpressionLeft;
  847. if(FAILED(CopySubPolicyExpression(pPRSubPolicyExpression2,pPRSubPolicyExpressionToCopy2,pPRRSLocal,pPRPolicy)))
  848. {
  849. return(E_OUTOFMEMORY);
  850. }
  851. pPRSubPolicyExpression->m_pPRPolicyExpressionLeft=pPRSubPolicyExpression2;
  852. }
  853. if(pPRSubPolicyExpressionToCopy->m_pPRPolicyExpressionRight!=NULL)
  854. {
  855. PICSRulesPolicyExpression * pPRSubPolicyExpression2,* pPRSubPolicyExpressionToCopy2;
  856. pPRSubPolicyExpression2=new PICSRulesPolicyExpression;
  857. if(pPRSubPolicyExpression2==NULL)
  858. {
  859. PICSRulesOutOfMemory();
  860. delete pPRRSLocal;
  861. pPRRSLocal = NULL;
  862. delete pPRPolicy;
  863. pPRPolicy = NULL;
  864. return(E_OUTOFMEMORY);
  865. }
  866. pPRSubPolicyExpressionToCopy2=pPRSubPolicyExpressionToCopy->m_pPRPolicyExpressionRight;
  867. if(FAILED(CopySubPolicyExpression(pPRSubPolicyExpression2,pPRSubPolicyExpressionToCopy2,pPRRSLocal,pPRPolicy)))
  868. {
  869. return(E_OUTOFMEMORY);
  870. }
  871. pPRSubPolicyExpression->m_pPRPolicyExpressionRight=pPRSubPolicyExpression2;
  872. }
  873. return(NOERROR);
  874. }
  875. HRESULT CAdvancedDialog::CopyArrayPRRSStructures(array<PICSRulesRatingSystem*> * parrpPRRSDest,array<PICSRulesRatingSystem*> * parrpPRRSSource)
  876. {
  877. DWORD dwCounter;
  878. PICSRulesRatingSystem * pPRRSLocal,* pPRRSBeingCopied;
  879. PICSRulesPolicy * pPRPolicy,* pPRPolicyBeingCopied;
  880. PICSRulesPolicyExpression * pPRPolicyExpression,* pPRPolicyExpressionBeingCopied;
  881. PICSRulesServiceInfo * pPRServiceInfo,* pPRServiceInfoBeingCopied;
  882. PICSRulesOptExtension * pPROptExtension,* pPROptExtensionBeingCopied;
  883. PICSRulesReqExtension * pPRReqExtension,* pPRReqExtensionBeingCopied;
  884. PICSRulesName * pPRName,* pPRNameBeingCopied;
  885. PICSRulesSource * pPRSource,* pPRSourceBeingCopied;
  886. PICSRulesByURL * pPRByURL,* pPRByURLToCopy;
  887. PICSRulesByURLExpression * pPRByURLExpression,* pPRByURLExpressionToCopy;
  888. if(parrpPRRSDest->Length()>0)
  889. {
  890. parrpPRRSDest->DeleteAll();
  891. }
  892. for(dwCounter=0;dwCounter<(DWORD) (parrpPRRSSource->Length());dwCounter++)
  893. {
  894. pPRRSLocal=new PICSRulesRatingSystem;
  895. if(pPRRSLocal==NULL)
  896. {
  897. PICSRulesOutOfMemory();
  898. return(E_OUTOFMEMORY);
  899. }
  900. pPRRSBeingCopied=(*parrpPRRSSource)[dwCounter];
  901. pPRRSLocal->m_etstrFile.Set(pPRRSBeingCopied->m_etstrFile.Get());
  902. pPRRSLocal->m_etnPRVerMajor.Set(pPRRSBeingCopied->m_etnPRVerMajor.Get());
  903. pPRRSLocal->m_etnPRVerMinor.Set(pPRRSBeingCopied->m_etnPRVerMinor.Get());
  904. pPRRSLocal->m_dwFlags=pPRRSBeingCopied->m_dwFlags;
  905. pPRRSLocal->m_nErrLine=pPRRSBeingCopied->m_nErrLine;
  906. if((pPRRSBeingCopied->m_pPRName)!=NULL)
  907. {
  908. pPRName=new PICSRulesName;
  909. if(pPRName==NULL)
  910. {
  911. PICSRulesOutOfMemory();
  912. delete pPRRSLocal;
  913. pPRRSLocal = NULL;
  914. return(E_OUTOFMEMORY);
  915. }
  916. pPRNameBeingCopied=pPRRSBeingCopied->m_pPRName;
  917. pPRName->m_etstrRuleName.Set(pPRNameBeingCopied->m_etstrRuleName.Get());
  918. pPRName->m_etstrDescription.Set(pPRNameBeingCopied->m_etstrDescription.Get());
  919. pPRRSLocal->m_pPRName=pPRName;
  920. }
  921. else
  922. {
  923. pPRRSLocal->m_pPRName=NULL;
  924. }
  925. if((pPRRSBeingCopied->m_pPRSource)!=NULL)
  926. {
  927. pPRSource=new PICSRulesSource;
  928. if(pPRSource==NULL)
  929. {
  930. PICSRulesOutOfMemory();
  931. delete pPRRSLocal;
  932. pPRRSLocal = NULL;
  933. return(E_OUTOFMEMORY);
  934. }
  935. pPRSourceBeingCopied=pPRRSBeingCopied->m_pPRSource;
  936. pPRSource->m_prURLSourceURL.Set(pPRSourceBeingCopied->m_prURLSourceURL.Get());
  937. pPRSource->m_etstrCreationTool.Set(pPRSourceBeingCopied->m_etstrCreationTool.Get());
  938. pPRSource->m_prEmailAuthor.Set(pPRSourceBeingCopied->m_prEmailAuthor.Get());
  939. pPRSource->m_prDateLastModified.Set(pPRSourceBeingCopied->m_prDateLastModified.Get());
  940. pPRRSLocal->m_pPRSource=pPRSource;
  941. }
  942. else
  943. {
  944. pPRRSLocal->m_pPRSource=NULL;
  945. }
  946. if(pPRRSBeingCopied->m_arrpPRPolicy.Length()>0)
  947. {
  948. DWORD dwSubCounter;
  949. for(dwSubCounter=0;dwSubCounter<(DWORD) (pPRRSBeingCopied->m_arrpPRPolicy.Length());dwSubCounter++)
  950. {
  951. DWORD dwPolicyExpressionSubCounter;
  952. pPRPolicy=new PICSRulesPolicy;
  953. pPRPolicyBeingCopied=pPRRSBeingCopied->m_arrpPRPolicy[dwSubCounter];
  954. if(pPRPolicy==NULL)
  955. {
  956. PICSRulesOutOfMemory();
  957. delete pPRRSLocal;
  958. pPRRSLocal = NULL;
  959. return(E_OUTOFMEMORY);
  960. }
  961. pPRPolicy->m_etstrExplanation.Set(pPRPolicyBeingCopied->m_etstrExplanation.Get());
  962. pPRPolicy->m_PRPolicyAttribute=pPRPolicyBeingCopied->m_PRPolicyAttribute;
  963. pPRByURLToCopy=NULL;
  964. pPRPolicyExpressionBeingCopied=NULL;
  965. switch(pPRPolicy->m_PRPolicyAttribute)
  966. {
  967. case PR_POLICY_ACCEPTBYURL:
  968. {
  969. pPRByURLToCopy=pPRPolicyBeingCopied->m_pPRAcceptByURL;
  970. pPRByURL=new PICSRulesByURL;
  971. if(pPRByURL==NULL)
  972. {
  973. PICSRulesOutOfMemory();
  974. delete pPRRSLocal;
  975. pPRRSLocal = NULL;
  976. delete pPRPolicy;
  977. pPRPolicy = NULL;
  978. return(E_OUTOFMEMORY);
  979. }
  980. pPRPolicy->m_pPRAcceptByURL=pPRByURL;
  981. break;
  982. }
  983. case PR_POLICY_REJECTBYURL:
  984. {
  985. pPRByURLToCopy=pPRPolicyBeingCopied->m_pPRRejectByURL;
  986. pPRByURL=new PICSRulesByURL;
  987. if(pPRByURL==NULL)
  988. {
  989. PICSRulesOutOfMemory();
  990. delete pPRRSLocal;
  991. pPRRSLocal = NULL;
  992. delete pPRPolicy;
  993. pPRPolicy = NULL;
  994. return(E_OUTOFMEMORY);
  995. }
  996. pPRPolicy->m_pPRRejectByURL=pPRByURL;
  997. break;
  998. }
  999. case PR_POLICY_REJECTIF:
  1000. {
  1001. pPRPolicyExpressionBeingCopied=pPRPolicyBeingCopied->m_pPRRejectIf;
  1002. pPRPolicyExpression=new PICSRulesPolicyExpression;
  1003. if(pPRPolicyExpression==NULL)
  1004. {
  1005. PICSRulesOutOfMemory();
  1006. delete pPRRSLocal;
  1007. pPRRSLocal = NULL;
  1008. delete pPRPolicy;
  1009. pPRPolicy = NULL;
  1010. return(E_OUTOFMEMORY);
  1011. }
  1012. pPRPolicy->m_pPRRejectIf=pPRPolicyExpression;
  1013. break;
  1014. }
  1015. case PR_POLICY_ACCEPTIF:
  1016. {
  1017. pPRPolicyExpressionBeingCopied=pPRPolicyBeingCopied->m_pPRAcceptIf;
  1018. pPRPolicyExpression=new PICSRulesPolicyExpression;
  1019. if(pPRPolicyExpression==NULL)
  1020. {
  1021. PICSRulesOutOfMemory();
  1022. delete pPRRSLocal;
  1023. pPRRSLocal = NULL;
  1024. delete pPRPolicy;
  1025. pPRPolicy = NULL;
  1026. return(E_OUTOFMEMORY);
  1027. }
  1028. pPRPolicy->m_pPRAcceptIf=pPRPolicyExpression;
  1029. break;
  1030. }
  1031. case PR_POLICY_REJECTUNLESS:
  1032. {
  1033. pPRPolicyExpressionBeingCopied=pPRPolicyBeingCopied->m_pPRRejectUnless;
  1034. pPRPolicyExpression=new PICSRulesPolicyExpression;
  1035. if(pPRPolicyExpression==NULL)
  1036. {
  1037. PICSRulesOutOfMemory();
  1038. delete pPRRSLocal;
  1039. pPRRSLocal = NULL;
  1040. delete pPRPolicy;
  1041. pPRPolicy = NULL;
  1042. return(E_OUTOFMEMORY);
  1043. }
  1044. pPRPolicy->m_pPRRejectUnless=pPRPolicyExpression;
  1045. break;
  1046. }
  1047. case PR_POLICY_ACCEPTUNLESS:
  1048. {
  1049. pPRPolicyExpressionBeingCopied=pPRPolicyBeingCopied->m_pPRAcceptUnless;
  1050. pPRPolicyExpression=new PICSRulesPolicyExpression;
  1051. if(pPRPolicyExpression==NULL)
  1052. {
  1053. PICSRulesOutOfMemory();
  1054. delete pPRRSLocal;
  1055. pPRRSLocal = NULL;
  1056. delete pPRPolicy;
  1057. pPRPolicy = NULL;
  1058. return(E_OUTOFMEMORY);
  1059. }
  1060. pPRPolicy->m_pPRAcceptUnless=pPRPolicyExpression;
  1061. break;
  1062. }
  1063. }
  1064. if(pPRByURLToCopy!=NULL)
  1065. {
  1066. for(dwPolicyExpressionSubCounter=0;
  1067. dwPolicyExpressionSubCounter<(DWORD) (pPRByURLToCopy->m_arrpPRByURL.Length());
  1068. dwPolicyExpressionSubCounter++)
  1069. {
  1070. pPRByURLExpression=new PICSRulesByURLExpression;
  1071. if(pPRByURLExpression==NULL)
  1072. {
  1073. PICSRulesOutOfMemory();
  1074. delete pPRRSLocal;
  1075. pPRRSLocal = NULL;
  1076. delete pPRPolicy;
  1077. pPRPolicy = NULL;
  1078. return(E_OUTOFMEMORY);
  1079. }
  1080. pPRByURLExpressionToCopy=pPRByURLToCopy->m_arrpPRByURL[dwPolicyExpressionSubCounter];
  1081. pPRByURLExpression->m_fInternetPattern=pPRByURLExpressionToCopy->m_fInternetPattern;
  1082. pPRByURLExpression->m_bNonWild=pPRByURLExpressionToCopy->m_bNonWild;
  1083. pPRByURLExpression->m_bSpecified=pPRByURLExpressionToCopy->m_bSpecified;
  1084. pPRByURLExpression->m_etstrScheme.Set(pPRByURLExpressionToCopy->m_etstrScheme.Get());
  1085. pPRByURLExpression->m_etstrUser.Set(pPRByURLExpressionToCopy->m_etstrUser.Get());
  1086. pPRByURLExpression->m_etstrHost.Set(pPRByURLExpressionToCopy->m_etstrHost.Get());
  1087. pPRByURLExpression->m_etstrPort.Set(pPRByURLExpressionToCopy->m_etstrPort.Get());
  1088. pPRByURLExpression->m_etstrPath.Set(pPRByURLExpressionToCopy->m_etstrPath.Get());
  1089. pPRByURLExpression->m_etstrURL.Set(pPRByURLExpressionToCopy->m_etstrURL.Get());
  1090. pPRByURL->m_arrpPRByURL.Append(pPRByURLExpression);
  1091. }
  1092. pPRRSLocal->m_arrpPRPolicy.Append(pPRPolicy);
  1093. }
  1094. if(pPRPolicyExpressionBeingCopied!=NULL)
  1095. {
  1096. BOOL fFlag;
  1097. fFlag=pPRPolicyExpressionBeingCopied->m_prYesNoUseEmbedded.GetYesNo();
  1098. pPRPolicyExpression->m_prYesNoUseEmbedded.Set(&fFlag);
  1099. pPRPolicyExpression->m_etstrServiceName.Set(pPRPolicyExpressionBeingCopied->m_etstrServiceName.Get());
  1100. pPRPolicyExpression->m_etstrCategoryName.Set(pPRPolicyExpressionBeingCopied->m_etstrCategoryName.Get());
  1101. pPRPolicyExpression->m_etstrFullServiceName.Set(pPRPolicyExpressionBeingCopied->m_etstrFullServiceName.Get());
  1102. pPRPolicyExpression->m_etnValue.Set(pPRPolicyExpressionBeingCopied->m_etnValue.Get());
  1103. pPRPolicyExpression->m_PROPolicyOperator=pPRPolicyExpressionBeingCopied->m_PROPolicyOperator;
  1104. pPRPolicyExpression->m_PRPEPolicyEmbedded=pPRPolicyExpressionBeingCopied->m_PRPEPolicyEmbedded;
  1105. if(pPRPolicyExpressionBeingCopied->m_pPRPolicyExpressionLeft!=NULL)
  1106. {
  1107. PICSRulesPolicyExpression * pPRSubPolicyExpression,* pPRSubPolicyExpressionToCopy;
  1108. pPRSubPolicyExpression=new PICSRulesPolicyExpression;
  1109. if(pPRSubPolicyExpression==NULL)
  1110. {
  1111. PICSRulesOutOfMemory();
  1112. delete pPRRSLocal;
  1113. pPRRSLocal = NULL;
  1114. delete pPRPolicy;
  1115. pPRPolicy = NULL;
  1116. return(E_OUTOFMEMORY);
  1117. }
  1118. pPRSubPolicyExpressionToCopy=pPRPolicyExpressionBeingCopied->m_pPRPolicyExpressionLeft;
  1119. if(FAILED(CopySubPolicyExpression(pPRSubPolicyExpression,pPRSubPolicyExpressionToCopy,pPRRSLocal,pPRPolicy)))
  1120. {
  1121. return(E_OUTOFMEMORY);
  1122. }
  1123. pPRPolicyExpression->m_pPRPolicyExpressionLeft=pPRSubPolicyExpression;
  1124. }
  1125. if(pPRPolicyExpressionBeingCopied->m_pPRPolicyExpressionRight!=NULL)
  1126. {
  1127. PICSRulesPolicyExpression * pPRSubPolicyExpression,* pPRSubPolicyExpressionToCopy;
  1128. pPRSubPolicyExpression=new PICSRulesPolicyExpression;
  1129. if(pPRSubPolicyExpression==NULL)
  1130. {
  1131. PICSRulesOutOfMemory();
  1132. delete pPRRSLocal;
  1133. pPRRSLocal = NULL;
  1134. delete pPRPolicy;
  1135. pPRPolicy = NULL;
  1136. return(E_OUTOFMEMORY);
  1137. }
  1138. pPRSubPolicyExpressionToCopy=pPRPolicyExpressionBeingCopied->m_pPRPolicyExpressionRight;
  1139. if(FAILED(CopySubPolicyExpression(pPRSubPolicyExpression,pPRSubPolicyExpressionToCopy,pPRRSLocal,pPRPolicy)))
  1140. {
  1141. return(E_OUTOFMEMORY);
  1142. }
  1143. pPRPolicyExpression->m_pPRPolicyExpressionRight=pPRSubPolicyExpression;
  1144. }
  1145. pPRRSLocal->m_arrpPRPolicy.Append(pPRPolicy);
  1146. }
  1147. }
  1148. }
  1149. if(pPRRSBeingCopied->m_arrpPRServiceInfo.Length()>0)
  1150. {
  1151. DWORD dwSubCounter;
  1152. for(dwSubCounter=0;dwSubCounter<(DWORD) (pPRRSBeingCopied->m_arrpPRServiceInfo.Length());dwSubCounter++)
  1153. {
  1154. BOOL fFlag;
  1155. pPRServiceInfo=new PICSRulesServiceInfo;
  1156. if(pPRServiceInfo==NULL)
  1157. {
  1158. PICSRulesOutOfMemory();
  1159. delete pPRRSLocal;
  1160. pPRRSLocal = NULL;
  1161. return(E_OUTOFMEMORY);
  1162. }
  1163. pPRServiceInfoBeingCopied=pPRRSBeingCopied->m_arrpPRServiceInfo[dwSubCounter];
  1164. pPRServiceInfo->m_prURLName.Set(pPRServiceInfoBeingCopied->m_prURLName.Get());
  1165. pPRServiceInfo->m_prURLBureauURL.Set(pPRServiceInfoBeingCopied->m_prURLBureauURL.Get());
  1166. pPRServiceInfo->m_etstrShortName.Set(pPRServiceInfoBeingCopied->m_etstrShortName.Get());
  1167. pPRServiceInfo->m_etstrRatfile.Set(pPRServiceInfoBeingCopied->m_etstrRatfile.Get());
  1168. fFlag=pPRServiceInfoBeingCopied->m_prYesNoUseEmbedded.GetYesNo();
  1169. pPRServiceInfo->m_prYesNoUseEmbedded.Set(&fFlag);
  1170. fFlag=pPRServiceInfoBeingCopied->m_prPassFailBureauUnavailable.GetPassFail();
  1171. pPRServiceInfo->m_prPassFailBureauUnavailable.Set(&fFlag);
  1172. pPRRSLocal->m_arrpPRServiceInfo.Append(pPRServiceInfo);
  1173. }
  1174. }
  1175. if(pPRRSBeingCopied->m_arrpPROptExtension.Length()>0)
  1176. {
  1177. DWORD dwSubCounter;
  1178. for(dwSubCounter=0;dwSubCounter<(DWORD) (pPRRSBeingCopied->m_arrpPROptExtension.Length());dwSubCounter++)
  1179. {
  1180. pPROptExtension=new PICSRulesOptExtension;
  1181. if(pPROptExtension==NULL)
  1182. {
  1183. PICSRulesOutOfMemory();
  1184. delete pPRRSLocal;
  1185. pPRRSLocal = NULL;
  1186. return(E_OUTOFMEMORY);
  1187. }
  1188. pPROptExtensionBeingCopied=pPRRSBeingCopied->m_arrpPROptExtension[dwSubCounter];
  1189. pPROptExtension->m_prURLExtensionName.Set(pPROptExtensionBeingCopied->m_prURLExtensionName.Get());
  1190. pPROptExtension->m_etstrShortName.Set(pPROptExtensionBeingCopied->m_etstrShortName.Get());
  1191. pPRRSLocal->m_arrpPROptExtension.Append(pPROptExtension);
  1192. }
  1193. }
  1194. if(pPRRSBeingCopied->m_arrpPRReqExtension.Length()>0)
  1195. {
  1196. DWORD dwSubCounter;
  1197. for(dwSubCounter=0;dwSubCounter<(DWORD) (pPRRSBeingCopied->m_arrpPRReqExtension.Length());dwSubCounter++)
  1198. {
  1199. pPRReqExtension=new PICSRulesReqExtension;
  1200. if(pPRReqExtension==NULL)
  1201. {
  1202. PICSRulesOutOfMemory();
  1203. delete pPRRSLocal;
  1204. pPRRSLocal = NULL;
  1205. return(E_OUTOFMEMORY);
  1206. }
  1207. pPRReqExtensionBeingCopied=pPRRSBeingCopied->m_arrpPRReqExtension[dwSubCounter];
  1208. pPRReqExtension->m_prURLExtensionName.Set(pPRReqExtensionBeingCopied->m_prURLExtensionName.Get());
  1209. pPRReqExtension->m_etstrShortName.Set(pPRReqExtensionBeingCopied->m_etstrShortName.Get());
  1210. pPRRSLocal->m_arrpPRReqExtension.Append(pPRReqExtension);
  1211. }
  1212. }
  1213. parrpPRRSDest->Append(pPRRSLocal);
  1214. }
  1215. return(NOERROR);
  1216. }