home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / dspppage.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  16.7 KB  |  691 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. // dspppage.cpp : implementation file
  20. //
  21.  
  22. #include "stdafx.h"
  23. #include "dspppage.h"
  24. #include "mailpriv.h"
  25.  
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31.  
  32.  
  33. #define DEF_DAYS 30
  34. #define DEF_KEEP_NEW 500
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CDiskSpacePropertyPage property page
  37. #ifndef _AFXDLL
  38. #define new DEBUG_NEW
  39. #endif
  40.  
  41. CDiskSpacePropertyPage::CDiskSpacePropertyPage(CNewsFolderPropertySheet *pParent,BOOL bDefaultPref,int nSelection, int nDays, int nKeepNew, BOOL bKeepUnread) 
  42.                         : CNetscapePropertyPage(CDiskSpacePropertyPage::IDD)
  43. {
  44.     //{{AFX_DATA_INIT(CDiskSpacePropertyPage)
  45.     m_bCheckDefault = bDefaultPref;
  46.     m_nKeepSelection= nSelection;
  47.     m_nDays = DEF_DAYS;//nDays;
  48.     m_nKeepNew = DEF_KEEP_NEW;//nKeepNew;
  49.     m_bCheckUnread = bKeepUnread;
  50.     //}}AFX_DATA_INIT
  51.     m_pParent = (CNewsFolderPropertySheet*)pParent;
  52.     m_pMoreDlg =  new CMoreChoicesDlg((CWnd*)this);
  53.     m_folderInfo = NULL;
  54. }
  55.  
  56. CDiskSpacePropertyPage::~CDiskSpacePropertyPage()
  57. {
  58.     if (m_pMoreDlg)
  59.         delete m_pMoreDlg;
  60. }
  61.  
  62. void CDiskSpacePropertyPage::SetFolderInfo( MSG_FolderInfo *folderInfo )
  63. {
  64.     m_folderInfo = folderInfo;
  65. }
  66.  
  67. BOOL CDiskSpacePropertyPage::OnSetActive()
  68. {
  69.     return CPropertyPage::OnSetActive();
  70. }
  71.  
  72. void CDiskSpacePropertyPage::DisableOthers(BOOL bChecked)
  73. {
  74.     //this is a toggle to the other windows of what
  75.     //ever the current state of IDC_CHECK2_DEFAULT is.  
  76.     EnableDisableItem(!bChecked,IDC_BNT_MORE);
  77.     EnableDisableItem(!bChecked,IDC_EDIT_DAYS);
  78.     EnableDisableItem(!bChecked,IDC_RADIO_KEEP1);
  79.     EnableDisableItem(!bChecked,IDC_RADIO_KEEP2);
  80.     EnableDisableItem(!bChecked,IDC_RADIO_KEEP3);
  81.     EnableDisableItem(!bChecked,IDC_EDIT_NEWEST);
  82.     EnableDisableItem(!bChecked,IDC_CHECK_KEEP4);
  83. }
  84.  
  85.  
  86. BOOL CDiskSpacePropertyPage::OnInitDialog()
  87. {
  88.     BOOL ret = CNetscapePropertyPage::OnInitDialog();
  89.     MSG_PurgeByPreferences    purgeBy;
  90.     int32    nDays;
  91.     int32    nKeepNew;
  92.  
  93.     //get the default start state
  94.     MSG_GetHeaderPurgingInfo(m_folderInfo, &m_bCheckDefault, &purgeBy,    &m_bCheckUnread, &nDays,    &nKeepNew);
  95.  
  96.     m_nDays = CASTINT(nDays);
  97.     m_nKeepNew = CASTINT(nKeepNew);
  98.  
  99.     switch ( purgeBy )
  100.     {
  101.     case MSG_PurgeByAge:
  102.         m_nKeepSelection = 0;
  103.         break;
  104.     case MSG_PurgeNone:
  105.         m_nKeepSelection = 1;
  106.         break;
  107.     case MSG_PurgeByNumHeaders:
  108.         m_nKeepSelection = 2;
  109.         break;
  110.     }
  111.     if (m_hWnd != NULL || IsWindow(m_hWnd))
  112.         UpdateData(FALSE);
  113.  
  114.     CheckDlgButton(IDC_CHECK_KEEP4,m_bCheckUnread);
  115.     return ret;
  116. }
  117.  
  118.  
  119. void CDiskSpacePropertyPage::DoDataExchange(CDataExchange* pDX)
  120. {
  121.     CPropertyPage::DoDataExchange(pDX);
  122.     //{{AFX_DATA_MAP(CDiskSpacePropertyPage)
  123.     DDX_Radio(pDX,IDC_RADIO_KEEP1,m_nKeepSelection);
  124.     DDX_Text(pDX, IDC_EDIT_DAYS, m_nDays);
  125.     DDV_MinMaxUInt(pDX, m_nDays, 0, 2000);
  126.     DDX_Text(pDX, IDC_EDIT_NEWEST, m_nKeepNew);
  127.     DDV_MinMaxUInt(pDX, m_nKeepNew, 0, 2000);
  128.     DDX_Check(pDX,IDC_CHECK_KEEP4,m_bCheckUnread);
  129.     //}}AFX_DATA_MAP
  130. }
  131.  
  132.  
  133. BEGIN_MESSAGE_MAP(CDiskSpacePropertyPage, CPropertyPage)
  134.     //{{AFX_MSG_MAP(CDiskSpacePropertyPage)
  135.     ON_BN_CLICKED(IDC_BNT_MORE, OnBtnMore)
  136.     ON_BN_CLICKED(IDC_DOWNLOAD_NOW, OnDownloadNow)
  137.     ON_EN_CHANGE(IDC_EDIT_DAYS, OnChangeEditDays)
  138.     ON_BN_CLICKED(IDC_RADIO_KEEP1, OnRdKeepDays)
  139.     ON_BN_CLICKED(IDC_RADIO_KEEP3, OnRdKeepNew)
  140.     ON_BN_CLICKED(IDC_RADIO_KEEP2, OnRdKeepall)
  141.     ON_EN_CHANGE(IDC_EDIT_NEWEST, OnChangeEditNewest)
  142.     ON_BN_CLICKED(IDC_CHECK_KEEP4,OnCheckUnread)
  143.  
  144.     //}}AFX_MSG_MAP
  145. END_MESSAGE_MAP()
  146.  
  147. /////////////////////////////////////////////////////////////////////////////
  148. // CDiskSpacePropertyPage message handlers
  149. void CDiskSpacePropertyPage::EnableDisableItem(BOOL bState, UINT nIDC)
  150. {   //disable or enable a dialog item window
  151.     CWnd *pWnd = GetDlgItem(nIDC);
  152.     if (pWnd)
  153.     {
  154.         pWnd->EnableWindow(bState);
  155.     }
  156. }
  157.  
  158. void CDiskSpacePropertyPage::OnCheckUnread()
  159. {
  160.     SetModified();
  161. }
  162.  
  163.  
  164. void CDiskSpacePropertyPage::OnBtnMore() 
  165. {
  166.     if(m_pMoreDlg)
  167.     {
  168.         MSG_PurgeByPreferences    purgeBy = MSG_PurgeNone;
  169.         int32    nDays = 30;
  170.         XP_Bool    useDefaults;
  171.  
  172.         MSG_GetArticlePurgingInfo(m_folderInfo, &useDefaults, &purgeBy, &nDays);
  173.         m_pMoreDlg->m_bCheck = (purgeBy == MSG_PurgeByAge) ? TRUE : FALSE;
  174.         m_pMoreDlg->m_nDays = CASTINT(nDays);
  175.         if (m_pMoreDlg->DoModal() == IDOK)
  176.         {
  177.             purgeBy = (m_pMoreDlg->m_bCheck) ? MSG_PurgeByAge : MSG_PurgeNone;
  178.             nDays = m_pMoreDlg->m_nDays;
  179.             MSG_SetArticlePurgingInfo(m_folderInfo, FALSE, purgeBy, nDays);
  180.         }
  181.     }
  182. }
  183.  
  184.  
  185. void CDiskSpacePropertyPage::OnDownloadNow()
  186. {
  187.     m_pParent->OnDownLoadButton();
  188. }
  189.  
  190.  
  191. void CDiskSpacePropertyPage::OnChangeEditDays() 
  192. {
  193.     UpdateData();
  194.     m_nKeepSelection=0;
  195.     UpdateData(FALSE);
  196.     SetModified();
  197. }
  198.  
  199. void CDiskSpacePropertyPage::OnRdKeepDays() 
  200. {
  201.     CWnd *pWnd = GetDlgItem(IDC_EDIT_DAYS);
  202.     if (pWnd)
  203.         GotoDlgCtrl(pWnd);
  204.     SetModified();
  205. }
  206.  
  207. void CDiskSpacePropertyPage::OnRdKeepNew() 
  208. {
  209.     CWnd *pWnd = GetDlgItem(IDC_EDIT_NEWEST);
  210.     if (pWnd)
  211.         GotoDlgCtrl(pWnd);
  212.     SetModified();
  213. }
  214.  
  215. void CDiskSpacePropertyPage::OnRdKeepall() 
  216. {
  217.     SetModified();
  218. }
  219.  
  220. void CDiskSpacePropertyPage::OnChangeEditNewest() 
  221. {
  222.     // TODO: Add your control notification handler code here
  223.     UpdateData();
  224.     m_nKeepSelection=2;
  225.     UpdateData(FALSE);
  226.     SetModified();
  227. }
  228.  
  229.  
  230. void CDiskSpacePropertyPage::OnOK() 
  231. {
  232.     if (m_hWnd == NULL || !IsWindow(m_hWnd))
  233.     {
  234.         CNetscapePropertyPage::OnOK();
  235.         return;
  236.     }
  237.  
  238.     MSG_PurgeByPreferences    purgeBy = MSG_PurgeNone;
  239.  
  240.  
  241.     UpdateData();
  242.  
  243.     switch ( m_nKeepSelection )
  244.     {
  245.     case 0:
  246.         purgeBy = MSG_PurgeByAge;
  247.         break;
  248.     case 1:
  249.         purgeBy = MSG_PurgeNone;
  250.         break;
  251.     case 2:
  252.         purgeBy = MSG_PurgeByNumHeaders;
  253.         break;
  254.     default:
  255.         XP_ASSERT(FALSE);
  256.         break;
  257.     }
  258.  
  259.     //we do not allow them to change toggle from default to manual settings.
  260.     //defaults only good for newly subscribed groups. Once manual settings are
  261.     //applied, they stay applied for now.
  262.     MSG_SetHeaderPurgingInfo(m_folderInfo, FALSE, purgeBy, m_bCheckUnread, (int32) m_nDays,    (int32) m_nKeepNew);
  263.     CNetscapePropertyPage::OnOK();
  264. }
  265.  
  266.  
  267.  
  268. /////CMoreChoicesDlg: called from CDiskSpacePropertyPage
  269.  
  270. CMoreChoicesDlg::CMoreChoicesDlg(CWnd* pParent)
  271.     : CDialog(CMoreChoicesDlg::IDD, pParent)
  272. {
  273.     //{{AFX_DATA_INIT(CMoreChoicesDlg)
  274.     m_bCheck = TRUE;
  275.     m_nDays = DEF_DAYS;
  276.     m_pParent = (CDiskSpacePropertyPage*)pParent;
  277.     //}}AFX_DATA_INIT
  278. }
  279.  
  280.  
  281. void CMoreChoicesDlg::DoDataExchange(CDataExchange* pDX)
  282. {
  283.     CDialog::DoDataExchange(pDX);
  284.     //{{AFX_DATA_MAP(CMoreChoicesDlg)
  285.     DDX_Check(pDX, IDC_CHECK1, m_bCheck);
  286.     DDX_Text(pDX, IDC_EDIT1, m_nDays);
  287.     DDV_MinMaxUInt(pDX, m_nDays, 0, 2000);
  288.     //}}AFX_DATA_MAP
  289. }
  290.  
  291.  
  292. BEGIN_MESSAGE_MAP(CMoreChoicesDlg, CDialog)
  293.     //{{AFX_MSG_MAP(CMoreChoicesDlg)
  294.     ON_BN_CLICKED(IDC_CHECK1, OnCheck)
  295.     ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit)
  296.     //}}AFX_MSG_MAP
  297. END_MESSAGE_MAP()
  298.  
  299. /////////////////////////////////////////////////////////////////////////////
  300. // CMoreChoicesDlg message handlers
  301.  
  302. void CMoreChoicesDlg::OnCheck() 
  303. {
  304.     // TODO: Add your control notification handler code here
  305.     if (m_pParent) 
  306.         m_pParent->SetModified();
  307.     CWnd *pWnd = GetDlgItem(IDC_EDIT1);
  308.     if (pWnd)
  309.         GotoDlgCtrl(pWnd);    
  310. }
  311.  
  312. void CMoreChoicesDlg::OnChangeEdit() 
  313. {
  314.     // TODO: Add your control notification handler code here
  315.       UpdateData();
  316.     if (m_pParent) 
  317.         m_pParent->SetModified();
  318.     UpdateData(FALSE);
  319.     CheckDlgButton(IDC_CHECK1,TRUE);
  320. }
  321.  
  322. void CMoreChoicesDlg::OnCancel() 
  323. {
  324.     CDialog::OnCancel();
  325.     if (m_pParent) 
  326.         m_pParent->SetModified(FALSE);
  327. }
  328.  
  329. void CMoreChoicesDlg::OnOK() 
  330. {
  331.     CDialog::OnOK();
  332. }
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339. /////////////////////////////////////////////////////////////////////////////
  340. // CDownLoadPPNews 
  341. // The download options property page used for Mail and News properties.
  342.  
  343.  
  344. CDownLoadPPNews::CDownLoadPPNews(CNewsFolderPropertySheet *pParent) : CNetscapePropertyPage(CDownLoadPPNews::IDD)
  345. {
  346.     //{{AFX_DATA_INIT(CNetscapePropertyPage)
  347.     m_bCheckArticles = FALSE;
  348.     m_bCheckDefault = FALSE;
  349.     m_bCheckDownLoad = FALSE;
  350.     m_bCheckByDate = FALSE;
  351.     m_nDaysAgo = 0;
  352.     m_nRadioValue = -1;
  353.     //}}AFX_DATA_INIT
  354.     m_pParent = (CNewsFolderPropertySheet*)pParent;
  355. }
  356.  
  357. CDownLoadPPNews::~CDownLoadPPNews()
  358. {
  359.  
  360. }
  361. void CDownLoadPPNews::SetFolderInfo( MSG_FolderInfo *folderInfo )
  362. {
  363.     m_folderInfo = folderInfo;
  364. }
  365.  
  366. void CDownLoadPPNews::DoDataExchange(CDataExchange* pDX)
  367. {
  368.     CNetscapePropertyPage::DoDataExchange(pDX);
  369.     //{{AFX_DATA_MAP(CDownLoadPPNews)
  370.     DDX_Check(pDX, IDC_CHECK_BY_ARTICLES, m_bCheckArticles);
  371.     DDX_Check(pDX, IDC_CHECK_DEFAULT, m_bCheckDefault);
  372.     DDX_Check(pDX, IDC_CHECK_DOWNLOAD, m_bCheckDownLoad);
  373.     DDX_Check(pDX, IDC_CHECK4_BY_DATE, m_bCheckByDate);
  374.     DDX_Text(pDX, IDC_EDIT_DAYS_AGO, m_nDaysAgo);
  375.     DDV_MinMaxUInt(pDX, m_nDaysAgo, 0, 1000);
  376.     DDX_Radio(pDX, IDC_RADIO_FROM, m_nRadioValue);
  377.     //}}AFX_DATA_MAP
  378. }
  379.  
  380.  
  381. BEGIN_MESSAGE_MAP(CDownLoadPPNews, CNetscapePropertyPage)
  382.     //{{AFX_MSG_MAP(CNetscapePropertyPage)
  383.     ON_BN_CLICKED(IDC_DOWNLOAD_NOW, OnDownloadNow)
  384.     ON_BN_CLICKED(IDC_CHECK_DEFAULT, OnCheckDefault)
  385.     ON_CBN_SETFOCUS(IDC_COMBO2, OnSetfocusCombo2)
  386.     ON_CBN_SELCHANGE(IDC_COMBO2, OnSelchangeCombo2)
  387.     ON_EN_CHANGE(IDC_EDIT_DAYS_AGO, OnChangeEditDaysAgo)
  388.     ON_BN_CLICKED(IDC_RADIO_SINCE, OnRadioSince)
  389.     ON_BN_CLICKED(IDC_RADIO_FROM, OnRadioFrom)
  390.     ON_BN_CLICKED(IDC_CHECK_BY_ARTICLES, OnCheckByArticles)
  391.     ON_BN_CLICKED(IDC_CHECK4_BY_DATE,OnCheckByDate)
  392.     //}}AFX_MSG_MAP
  393. END_MESSAGE_MAP()
  394.  
  395. /////////////////////////////////////////////////////////////////////////////
  396. // CDownLoadPPNews message handlers
  397.  
  398. void CDownLoadPPNews::OnDownloadNow()
  399. {
  400.     m_pParent->OnDownLoadButton();
  401. }
  402.  
  403. void CDownLoadPPNews::DisableOthers(BOOL bChecked)
  404. {
  405.     //this is a toggle to the other windows of what
  406.     //ever the current state of IDC_CHECK_DEFAULT is.  
  407.     EnableDisableItem(!bChecked,IDC_COMBO2);
  408.     EnableDisableItem(!bChecked,IDC_EDIT_DAYS_AGO);
  409.     EnableDisableItem(!bChecked,IDC_RADIO_SINCE);
  410.     EnableDisableItem(!bChecked,IDC_RADIO_FROM);
  411.     EnableDisableItem(!bChecked,IDC_CHECK_BY_ARTICLES);
  412.     EnableDisableItem(!bChecked,IDC_CHECK4_BY_DATE);
  413. }
  414.  
  415.  
  416. void CDownLoadPPNews::EnableDisableItem(BOOL bState, UINT nIDC)
  417. {   //disable or enable a dialog item window
  418.     CWnd *pWnd = GetDlgItem(nIDC);
  419.     if (pWnd)
  420.     {
  421.         pWnd->EnableWindow(bState);
  422.     }
  423. }
  424.  
  425. void CDownLoadPPNews::OnCheckDefault() 
  426. {
  427.     DisableOthers(IsDlgButtonChecked(IDC_CHECK_DEFAULT));
  428.     UpdateData();
  429. }
  430.  
  431. void CDownLoadPPNews::OnCheckByDate() 
  432. {
  433.     //we want to default to the from radio on check by date
  434.     if (IsDlgButtonChecked(IDC_CHECK4_BY_DATE))
  435.     {
  436.         if (IsDlgButtonChecked(IDC_RADIO_SINCE))
  437.             CheckDlgButton(IDC_RADIO_SINCE,FALSE);
  438.  
  439.         CWnd *pWnd = GetDlgItem(IDC_COMBO2);
  440.         CheckDlgButton(IDC_RADIO_FROM,TRUE);
  441.         if (pWnd)
  442.             GotoDlgCtrl(pWnd);
  443.         SetModified();
  444.     }
  445.     UpdateData();
  446. }
  447.  
  448.  
  449.  
  450. void CDownLoadPPNews::OnSetfocusCombo2() 
  451. {
  452.     // TODO: Add your control notification handler code here
  453.  
  454.     CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_COMBO2);
  455.     if (pCombo)
  456.         pCombo->SetCurSel(0);
  457.     UpdateData();
  458. }
  459.  
  460. void CDownLoadPPNews::OnSelchangeCombo2() 
  461. {
  462.     // TODO: Add your control notification handler code here
  463.     if (IsDlgButtonChecked(IDC_RADIO_SINCE))
  464.     {
  465.         CheckDlgButton(IDC_RADIO_SINCE,FALSE);
  466.         CheckDlgButton(IDC_RADIO_FROM,TRUE);
  467.     }
  468.     
  469.     if (!IsDlgButtonChecked(IDC_CHECK4_BY_DATE))
  470.         CheckDlgButton(IDC_CHECK4_BY_DATE,TRUE);
  471.  
  472.     UpdateData();
  473.     SetModified();
  474. }
  475.  
  476. void CDownLoadPPNews::OnChangeEditDaysAgo() 
  477. {
  478.  
  479.     BOOL ret = UpdateData();
  480.     m_nRadioValue = 1;
  481.     SetModified();    
  482.     UpdateData(FALSE);
  483.     if(!IsDlgButtonChecked(IDC_CHECK4_BY_DATE))
  484.         CheckDlgButton(IDC_CHECK4_BY_DATE,TRUE);
  485. }
  486.  
  487. void CDownLoadPPNews::OnRadioSince() 
  488. {
  489.     // TODO: Add your control notification handler code here
  490.     CWnd *pWnd = GetDlgItem(IDC_EDIT_DAYS_AGO);
  491.     if (pWnd)
  492.         GotoDlgCtrl(pWnd);
  493.  
  494.     UpdateData();
  495.     SetModified();
  496. }
  497.  
  498. void CDownLoadPPNews::OnRadioFrom() 
  499. {
  500.     CWnd *pWnd = GetDlgItem(IDC_COMBO2);
  501.     if (pWnd)
  502.         GotoDlgCtrl(pWnd);
  503.     SetModified();    
  504. }
  505.  
  506. void CDownLoadPPNews::OnCheckByArticles() 
  507. {
  508.     // TODO: Add your control notification handler code here
  509.     UpdateData();
  510.     SetModified();
  511. }
  512.  
  513. void CDownLoadPPNews::OnOK() 
  514. {
  515.     if (m_hWnd == NULL || !IsWindow(m_hWnd))
  516.     {
  517.         CNetscapePropertyPage::OnOK();
  518.         return;
  519.     }
  520.     UpdateData(TRUE);
  521.  
  522.  
  523.     if (m_nRadioValue  == 0)
  524.     {
  525.         CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_COMBO2);
  526.         if (pCombo)
  527.         {
  528.             switch (pCombo->GetCurSel())
  529.             {
  530.             case 0:
  531.                 m_nDaysAgo = 1;
  532.                 break;
  533.             case 1:
  534.                 m_nDaysAgo = 7;
  535.                 break;
  536.             case 2:
  537.                 m_nDaysAgo = 14;
  538.                 break;
  539.             case 3:
  540.                 m_nDaysAgo = 31;
  541.                 break;
  542.             case 4:
  543.                 m_nDaysAgo = 183;
  544.                 break;
  545.             case 5:
  546.                 m_nDaysAgo = 365;
  547.                 
  548.             }
  549.         }
  550.     }
  551.     if (m_bCheckDownLoad)
  552.         MSG_SetFolderPrefFlags(m_folderInfo, MSG_GetFolderPrefFlags(m_folderInfo) | MSG_FOLDER_PREF_OFFLINE);
  553.     else
  554.         MSG_SetFolderPrefFlags(m_folderInfo, MSG_GetFolderPrefFlags(m_folderInfo) & ~MSG_FOLDER_PREF_OFFLINE);
  555.  
  556.     MSG_SetOfflineRetrievalInfo(m_folderInfo, m_bCheckDefault, m_bCheckArticles, m_bCheckArticles, m_bCheckByDate, m_nDaysAgo);
  557.  
  558.     CNetscapePropertyPage::OnOK();
  559. }
  560.  
  561. BOOL CDownLoadPPNews::OnInitDialog() 
  562. {
  563.     BOOL bRet = CNetscapePropertyPage::OnInitDialog();
  564.     XP_Bool bUnreadOnly = FALSE;
  565.     int    iComboSel = -1;
  566.     int32    i32DaysAgo;
  567.     MSG_GetOfflineRetrievalInfo(m_folderInfo, &m_bCheckDefault, &m_bCheckArticles, &bUnreadOnly, &m_bCheckByDate, &i32DaysAgo);
  568.  
  569.  
  570.     CheckDlgButton(IDC_CHECK_BY_ARTICLES,m_bCheckArticles);
  571.     CheckDlgButton(IDC_CHECK4_BY_DATE,m_bCheckByDate);
  572.     
  573.     switch (i32DaysAgo)
  574.     {
  575.     case 1:
  576.         iComboSel = 0;
  577.         break;
  578.     case 7:
  579.         iComboSel = 1;
  580.         break;
  581.     case 14:
  582.         iComboSel = 2;
  583.         break;
  584.     case 31:
  585.         iComboSel = 3;
  586.         break;
  587.     case 183:
  588.         iComboSel = 4;
  589.         break;
  590.     case 365:
  591.         iComboSel = 5;
  592.     }
  593.     if (m_bCheckByDate) {
  594.         if (iComboSel != -1) {
  595.             CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_COMBO2);
  596.             if (pCombo) {
  597.                 pCombo->SetCurSel(iComboSel);
  598.             }
  599.             m_nRadioValue = 0;
  600.             CheckDlgButton(IDC_RADIO_FROM,TRUE);
  601.         }
  602.         else
  603.         {
  604.             m_nRadioValue = 1;
  605.             m_nDaysAgo=i32DaysAgo;
  606.             CheckDlgButton(IDC_RADIO_SINCE,TRUE);
  607.         }
  608.     }
  609.     m_bCheckDownLoad = MSG_GetFolderPrefFlags(m_folderInfo) & MSG_FOLDER_PREF_OFFLINE;
  610.     CheckDlgButton(IDC_CHECK_DOWNLOAD,m_bCheckDownLoad);
  611.     CheckDlgButton(IDC_CHECK_DEFAULT,m_bCheckDefault);
  612.     DisableOthers(m_bCheckDefault);
  613.     UpdateData(FALSE);
  614.     return bRet;
  615. }
  616.  
  617. BOOL CDownLoadPPNews::OnSetActive() 
  618. {
  619.     return CNetscapePropertyPage::OnSetActive();    
  620. }
  621.  
  622.  
  623.  
  624.  
  625. /////////////////////////////////////////////////////////////////////////////
  626. // CDownLoadPPNews 
  627. // The download options property page used for Mail and News properties.
  628.  
  629.  
  630. CDownLoadPPMail::CDownLoadPPMail() : CNetscapePropertyPage(CDownLoadPPMail::IDD)
  631. {
  632.     //{{AFX_DATA_INIT(CNetscapePropertyPage)
  633.     m_bCheckDownLoadMail = FALSE;
  634.     //}}AFX_DATA_INIT
  635. }
  636.  
  637. CDownLoadPPMail::~CDownLoadPPMail()
  638. {
  639. }
  640.  
  641. void CDownLoadPPMail::DoDataExchange(CDataExchange* pDX)
  642. {
  643.     CNetscapePropertyPage::DoDataExchange(pDX);
  644.     //{{AFX_DATA_MAP(CDownLoadPPMail)
  645.     DDX_Check(pDX, IDC_CHECK1, m_bCheckDownLoadMail);
  646.     //}}AFX_DATA_MAP
  647. }
  648.  
  649.  
  650. BEGIN_MESSAGE_MAP(CDownLoadPPMail, CNetscapePropertyPage)
  651.     //{{AFX_MSG_MAP(CNetscapePropertyPage)
  652.     ON_BN_CLICKED(IDC_CHECK_DEFAULT, OnCheckDownLoad)
  653.     //}}AFX_MSG_MAP
  654. END_MESSAGE_MAP()
  655.  
  656. /////////////////////////////////////////////////////////////////////////////
  657. // CDownLoadPPNews message handlers
  658.  
  659. void CDownLoadPPMail::OnCheckDownLoad() 
  660. {
  661. }
  662.  
  663. void CDownLoadPPMail::SetFolderInfo(MSG_FolderInfo *pfolderInfo)
  664. {
  665.     m_pfolderInfo = pfolderInfo;
  666. }
  667.  
  668. void CDownLoadPPMail::OnOK() 
  669. {
  670.     if (m_hWnd == NULL || !IsWindow(m_hWnd))
  671.     {
  672.         CNetscapePropertyPage::OnOK();
  673.         return;
  674.     }
  675.     CNetscapePropertyPage::OnOK();
  676.  
  677.     MSG_SetFolderPrefFlags(m_pfolderInfo, (m_bCheckDownLoadMail == 1 ? MSG_FOLDER_PREF_OFFLINE : !MSG_FOLDER_PREF_OFFLINE) );
  678.  
  679.     // TODO: Add your specialized code here and/or call the base class
  680. }
  681.  
  682. BOOL CDownLoadPPMail::OnInitDialog() 
  683. {
  684.     BOOL ret = CNetscapePropertyPage::OnInitDialog();
  685.     // TODO: Add your specialized code here and/or call the base class
  686.     m_bCheckDownLoadMail = MSG_FOLDER_PREF_OFFLINE & MSG_GetFolderPrefFlags(m_pfolderInfo);
  687.  
  688.     UpdateData(FALSE);
  689.     return ret;
  690. }
  691.