⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mailsettings.cpp

📁 funambol window mobile客户端源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*
 * Funambol is a mobile platform developed by Funambol, Inc. 
 * Copyright (C) 2003 - 2007 Funambol, Inc.
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by
 * the Free Software Foundation with the addition of the following permission
 * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
 * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT  OF THIRD PARTY RIGHTS.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 
 * details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program; if not, see http://www.gnu.org/licenses or write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301 USA.
 * 
 * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite
 * 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Powered by Funambol" logo. If the display of the logo is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Powered by Funambol".
 */

// MailSettings.cpp : implementation file
//

#include "stdafx.h"
#include "ui.h"
#include "MailSettings.h"
#include "MailSettingsAdvanced.h"
#include "pim/ClientSettings.h"
#include "pim/ConfigParams.h"

#include "ClientUtil.h"
#include "examples/config.h"
#include "base/fscapi.h"
#include "spds/constants.h"
#include "spdm/DMTree.h"
#include "spdm/DMTreeFactory.h"
#include "spdm/ManagementNode.h"
#include "hwndfunctions.h"
#include "pim/Maincpp.h"
#include "notify/timed_msgbox.h"


#define ENABLE_CHECK_FOR_FILTER     0

int getMsgSizePosition(int value) {
    switch(value){
        case 2:  return 0;
        case 5:  return 1;
        case 10: return 2;
        case 25: return 3;
        case 50: return 4;
        case 100: return 5;
        case 250: return 6;
        case -1: return 7;
    }

    return 3; //default
}

IMPLEMENT_DYNAMIC(CMailSettings, CDialog)

CMailSettings::CMailSettings(CWnd* pParent /*=NULL*/)
	: CDialog(CMailSettings::IDD, pParent)
{

}

CMailSettings::~CMailSettings()
{
}

void CMailSettings::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
#if defined(WIN32_PLATFORM_WFSP)
    DDX_Control(pDX, IDC_SETTMAIL_SPIN1, spinSyncType );
    DDX_Control(pDX, IDC_SETTMAIL_SPIN2, spinMailSince );
    DDX_Control(pDX, IDC_SETTMAIL_SPIN3, spinMsgSize );
#endif
    DDX_Control(pDX, IDC_MAIL_SYNCTYPE, lstSyncType );
    DDX_Control(pDX, IDC_FILTERS_MAILSINCE, lstMailSince );
    DDX_Control(pDX, IDC_FILTERS_MSGSIZE, lstMsgSize );
    DDX_Control(pDX, IDC_MAIL_LINK_ADVANCED, linkAdvanced);
    DDX_Control(pDX, IDC_MAIL_CHECK_ATTACHMENTS, checkAttachments);
    DDX_Control(pDX, IDC_MAIL_CHECK_FILTER, checkFilter);
}


BEGIN_MESSAGE_MAP(CMailSettings, CDialog)
    #if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
        ON_WM_SIZE()
    #endif
    ON_BN_CLICKED(IDC_MAIL_LINK_ADVANCED,  &CMailSettings::OnBnClickedMailLinkAdvanced)
    ON_COMMAND(ID_MENU_ADVANCEDSETTINGS,   &CMailSettings::OnBnClickedMailLinkAdvanced)
    ON_MESSAGE(ID_MYMSG_CONFIG_SYNC_ENDED, &CMailSettings::OnMsgConfigSyncEnded)
    
    ON_WM_CTLCOLOR()
END_MESSAGE_MAP()



BOOL CMailSettings::OnInitDialog() {

    CString s1;
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_MAIL_SETTINGS); SetWindowText(s1);
    CDialog::OnInitDialog();

    // Link for advanced settings is actually hidden.
    // linkAdvanced.ShowWindow(FALSE);
    if (ENABLE_CHECK_FOR_FILTER == 0) {        
        // Filter: currently disabled    
        checkFilter.ShowWindow(SW_HIDE);
    }

#if defined(WIN32_PLATFORM_WFSP)
    spinSyncType.SetRange(2,0);	 spinSyncType.SetBuddy(&lstSyncType);
    spinMailSince.SetRange(5,0); spinMailSince.SetBuddy(&lstMailSince);
    spinMsgSize.SetRange(7,0);	 spinMsgSize.SetBuddy(&lstMsgSize);
#endif

    ZeroMemory(&dlgCommandBar, sizeof(SHMENUBARINFO));
    dlgCommandBar.cbSize = sizeof(SHMENUBARINFO);
    dlgCommandBar.hwndParent = this->GetSafeHwnd();
    dlgCommandBar.dwFlags = SHCMBF_HMENU;
    dlgCommandBar.nToolBarId = IDM_MAIL_SAVE_CANCEL;
#if defined WIN32_PLATFORM_WFSP
#if (_WIN32_WCE < 0x500)
    dlgCommandBar.nToolBarId = IDR_MENUBAR_OKCANCEL;
#endif
#endif
    dlgCommandBar.hInstRes = getLocalizationUtils()->getLocaleResource();
    dlgCommandBar.nBmpId = 0;
    dlgCommandBar.cBmpImages = 0;
    if(!SHCreateMenuBar(&dlgCommandBar)){
        TRACE(_T("Cannot create command bar!"));
        return FALSE;
    }


    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_MAIL_SYNCTYPE1); lstSyncType.AddString(s1);

    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_FILTERS_DOWNMAIL_ALL);    lstMailSince.AddString(s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_FILTERS_DOWNMAIL_0DAY);   lstMailSince.AddString(s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_FILTERS_DOWNMAIL_3DAY);   lstMailSince.AddString(s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_FILTERS_DOWNMAIL_5DAY);   lstMailSince.AddString(s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_FILTERS_DOWNMAIL_7DAY);   lstMailSince.AddString(s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_FILTERS_DOWNMAIL_10DAY);  lstMailSince.AddString(s1);

    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_FILTERS_GETMSGSIZE_2K);   lstMsgSize.AddString(s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_FILTERS_GETMSGSIZE_5K);   lstMsgSize.AddString(s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_FILTERS_GETMSGSIZE_10K);  lstMsgSize.AddString(s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_FILTERS_GETMSGSIZE_25K);  lstMsgSize.AddString(s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_FILTERS_GETMSGSIZE_50K);  lstMsgSize.AddString(s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_FILTERS_GETMSGSIZE_100K); lstMsgSize.AddString(s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_FILTERS_GETMSGSIZE_250K); lstMsgSize.AddString(s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_FILTERS_GETMSGSIZE_500K); lstMsgSize.AddString(s1);

    LoadStringResources();

    // create and set the bold font
    LOGFONT lf;
    memset(&lf, 0, sizeof(LOGFONT));
    HFONT hFont = (HFONT) GetStockObject(SYSTEM_FONT);
    GetObject(hFont, sizeof lf, &lf);
    lf.lfWeight = FW_BOLD;
    lf.lfHeight +=FONT_HEIGHT_OFFSET;
    VERIFY(fontBold.CreateFontIndirect(&lf));

    GetDlgItem(IDC_SETTMAIL_STATIC_SYNCTYPE)->SetFont(&fontBold);
    GetDlgItem(IDC_MAIL_STATIC_DOWNLOAD    )->SetFont(&fontBold);
    GetDlgItem(IDC_ALERT                   )->SetFont(&fontBold);

    GetDlgItem(IDC_ALERT)->ShowWindow(SW_HIDE);

    // set ppc header
#if defined(WIN32_PLATFORM_PSPC)
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_MAIL_SETTINGS); SetDlgItemText(IDC_HEADER_STATIC, s1);
    GetDlgItem(IDC_HEADER_STATIC)->SetFont(&fontBold);
#endif

    // read from the registry
    ClientSettings* cs = getRegConfig();
    int pos=0;

    // Download mail since
    pos=0;
    switch(cs->mailssconfig->getDownloadAge())
    {
        case -1: pos=0; break;
        case 0: pos=1; break;
        case 3: pos=2; break;
        case 5: pos=3; break;
        case 7: pos=4; break;
        case 10: pos=5; break;
    };
    lstMailSince.SetCurSel(pos);

    // mail size
    pos=0;
    lstMsgSize.SetCurSel(getMsgSizePosition(cs->mailssconfig->getAttachSize()));

    // attachments
    if (cs->mailssconfig->getBodySize() == -1){
        checkAttachments.SetCheck(BST_CHECKED);
    }

    
    if (ENABLE_CHECK_FOR_FILTER) {
        // Filter
        WindowsSyncSourceConfig* ssc = cs->getWinSyncSourceConfig("config");
        if ( ssc && (strcmp(ssc->getSync(), "none")) ) {
            if (cs->getEmailFilter() == "1") {
                checkFilter.SetCheck(BST_CHECKED);
            }
        }
        else {
            // SSource "config" is not supported on Server (we had a 404): hide checkbox.
            checkFilter.EnableWindow(SW_HIDE);
        }
    }

    // fix for wrong title problem, we get & set the title for the main window
    wchar_t title[256];
    AfxGetMainWnd()->GetWindowText(title,256);
    AfxGetMainWnd()->SetWindowText(title);

    return FALSE;
}




// CMailSettings message handlers

void CMailSettings::OnOK()
{
	// save values in registry
   ClientSettings* cs = getRegConfig();
   CString s1, s2; int pos=0;
   BOOL dirtyFlag=FALSE;

   if(checkStartSync()){
       CDialog::OnOK();
   }

  // pos = lstSyncType.GetCurSel();

    //
    // set type of sync
    //
 /*  if(pos == 0){
       cs->mailssconfig->setSync("two-way");
   } else if(pos == 1){
        cs->mailssconfig->setSync("one-way-server");
   } else if(pos == 2) {
       cs->mailssconfig->setSync("one-way-client");
   }
*/
    // mail since
    int value=-1;
    pos = lstMailSince.GetCurSel();

    switch(pos)
    {
    case 0: value=-1;break;
    case 1: value=0;break;
    case 2: value=3;break;
    case 3: value=5;break;
    case 4: value=7;break;
    case 5: value=10;break;
    }
    if(cs->mailssconfig->getDownloadAge() != value){
        cs->mailssconfig->setDownloadAge(value);
        getRegConfig()->setDirty(CS_DIRTY_SOURCE_MAIL);
        dirtyFlag = TRUE;
    }

    // mail size
    pos=0; value=-1;
    pos = lstMsgSize.GetCurSel();
    switch(pos)
    {
    case 0: value=2;break;
    case 1: value=5;break;
    case 2: value=10;break;
    case 3: value=25;break;
    case 4: value=50;break;
    case 5: value=100;break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -