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

📄 recoversettings.cpp

📁 funambol windows mobile plugin source code, the source code is taken from the funambol site
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*
 * 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 General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 * 02111-1307  USA
 */

// RecoverSettings.cpp : implementation file
//

#include "stdafx.h"
#include "ui.h"
#include "uiDlg.h"
#include "RecoverSettings.h"
#include "pim/utils.h"
#include "pim/Maincpp.h"
#include "base/startcmd.h"
#include "pim/SettingFunctions.h"
#include "pim/ClientSettings.h"
#include "pim/account.h"
#include "ClientUtil.h"
#include "notify/timed_msgbox.h"
#include "HwndFunctions.h"
#include "winreg.h"
#include <vector>
#include "localizationUtils.h"


static int checkRefreshFromServer(HWND wndUI, vector<const wchar_t*> sources);
static wstring getCommandLine(vector<const wchar_t*> sources);

// CRecoverSettings dialog
void writeSourceForSlow(const wchar_t*  value);
IMPLEMENT_DYNAMIC(CRecoverSettings, CDialog)

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

}

CRecoverSettings::~CRecoverSettings()
{
}

void CRecoverSettings::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_RECOVER_CONTACTS, checkContacts);
    DDX_Control(pDX, IDC_RECOVER_CALENDAR, checkCalendar);
    DDX_Control(pDX, IDC_RECOVER_TASKS, checkTasks);
    DDX_Control(pDX, IDC_RECOVER_MAIL, checkMail);
    DDX_Control(pDX, IDC_RECOVER_BRIEFCASE, checkBriefcase);
    #if defined(WIN32_PLATFORM_WFSP)
        DDX_Control(pDX, IDC_RECOVER_SPIN1, spinSyncType );
    #endif
    DDX_Control(pDX, IDC_RECOVER_LIST_SYNCTYPE, lstSyncType );

    #if defined(WIN32_PLATFORM_PSPC)
        DDX_Control(pDX, IDC_RECOVER_NOTES, checkNotes);
    #endif
}


BEGIN_MESSAGE_MAP(CRecoverSettings, CDialog)
    ON_BN_CLICKED(IDC_RECOVER_MAIL, &CRecoverSettings::OnBnClickedRecoverMail)
    ON_BN_CLICKED(IDC_RECOVER_CALENDAR, &CRecoverSettings::OnBnClickedRecoverCalendar)
    ON_BN_CLICKED(IDC_RECOVER_CONTACTS, &CRecoverSettings::OnBnClickedRecoverContacts)
    ON_BN_CLICKED(IDC_RECOVER_TASKS, &CRecoverSettings::OnBnClickedRecoverTasks)
    ON_BN_CLICKED(IDC_RECOVER_BRIEFCASE, &CRecoverSettings::OnBnClickedRecoverBriefcase)
    #if defined(WIN32_PLATFORM_PSPC)
        ON_BN_CLICKED(IDC_RECOVER_NOTES, &CRecoverSettings::OnBnClickedRecoverNotes)
    #endif
    ON_WM_SIZE()
    ON_LBN_SELCHANGE(IDC_RECOVER_LIST_SYNCTYPE, &CRecoverSettings::OnLbnSelchangeRecoverListSynctype)
END_MESSAGE_MAP()


// CRecoverSettings message handlers

BOOL CRecoverSettings::OnInitDialog()
{
    CString s1, s2;
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER); SetWindowText(s1);
    CDialog::OnInitDialog();

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

    #ifdef WIN32_PLATFORM_WFSP
        spinSyncType.SetRange(2,0);	spinSyncType.SetBuddy(&lstSyncType);
    #endif

    // load string resources
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_SYNCTYPE2); lstSyncType.AddString(s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_SYNCTYPE3); lstSyncType.AddString(s1);
    lstSyncType.SetCurSel(0);

    s2.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_ITEMS);   SetDlgItemText(IDC_RECOVER_STATIC, s2);

    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_CONTACTS);	SetDlgItemText(IDC_RECOVER_CONTACTS, s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_CALENDAR);	SetDlgItemText(IDC_RECOVER_CALENDAR, s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_TASKS);   	SetDlgItemText(IDC_RECOVER_TASKS, s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_ITEMS);   	SetDlgItemText(IDC_RECOVER_STATIC, s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_BRIEFCASE);   SetDlgItemText(IDC_RECOVER_BRIEFCASE, s1);
    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_DIRECTION);        SetDlgItemText(IDC_RECOVER_STATIC_DIRECTION, s1);

    s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_MAIL);  s1+=" "; s2.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_EMAIL_SYNCTYPE);
    s1+=s2;
    SetDlgItemText(IDC_RECOVER_MAIL, s1);

    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_RECOVER_STATIC)->SetFont(&fontBold);
    GetDlgItem(IDC_RECOVER_STATIC_DIRECTION)->SetFont(&fontBold);

    // check what sources are set to synctype none, and disable the checkboxes
    ClientSettings* cs = getRegConfig();

    if(!strcmp(cs->getConfigSourcesParameter("contact", "sync"),"none")){
        checkContacts.EnableWindow(FALSE);
    }

    if(!strcmp(cs->getConfigSourcesParameter("calendar", "sync"),"none")){
        checkCalendar.EnableWindow(FALSE);
    }

    if(!strcmp(cs->getConfigSourcesParameter("task", "sync"),"none")){
        checkTasks.EnableWindow(FALSE);
    }

    if(!strcmp(cs->getConfigSourcesParameter("briefcase", "sync"),"none")){
        checkBriefcase.EnableWindow(FALSE);
    }

    #if defined(WIN32_PLATFORM_PSPC)
    if(!strcmp(cs->getConfigSourcesParameter("note", "sync"),"none")){
        checkNotes.EnableWindow(FALSE);
    }
    #endif

    if(!strcmp(cs->getConfigSourcesParameter("mail", "sync"),"none") ||
        !doesFunambolAccountExist()){
       checkMail.EnableWindow(FALSE);
    }

    if(cs->getIsPortal()){
        checkBriefcase.EnableWindow(FALSE);
        checkBriefcase.ShowWindow(SW_HIDE);
        #if defined(WIN32_PLATFORM_PSPC)
            checkNotes.EnableWindow(FALSE);
            checkNotes.ShowWindow(SW_HIDE);
        #endif
    }

    EnableRecoverButton(false);

    // 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);

    checkMail.SetFocus();
    return FALSE;
}


void CRecoverSettings::OnOK()
{
    wstring command;
    int nCheckedSources = 0;
    int firstSourceToSyncId = -1;
    vector<const wchar_t*> sourceToSync;
    BOOL mailToRecover = FALSE;

    if(lstSyncType.GetCurSel() == 0) {
        command += L"refresh-from-server ";
        mailToRecover = TRUE;
    } else if(lstSyncType.GetCurSel() == 1) {
        command += L"refresh-from-client ";
        mailToRecover = FALSE;
    }

    if(checkMail.GetCheck() == BST_CHECKED && doesFunambolAccountExist()) {
        if (mailToRecover) {
            firstSourceToSyncId = SOURCE_MAIL;
            sourceToSync.push_back(MAILS_NAME);
            nCheckedSources++;
            // we need to know if this source is to be synced,
            // in the case when the sync is canceled, to display the appropriate text
            ((CuiDlg*)AfxGetMainWnd())->getSourceListCtrl().setState(SOURCE_MAIL, ITEM_STATE_TO_SYNC);
        }
    }

    if (checkContacts.GetCheck() == BST_CHECKED) {
        if(firstSourceToSyncId == -1) {             //not set
            firstSourceToSyncId = SOURCE_CONTACTS;
        }
        sourceToSync.push_back(CONTACTS_NAME);
        nCheckedSources ++;
        ((CuiDlg*)AfxGetMainWnd())->getSourceListCtrl().setState(SOURCE_CONTACTS, ITEM_STATE_TO_SYNC);
    }

    if(checkCalendar.GetCheck() == BST_CHECKED) {
        if(firstSourceToSyncId == -1) {             //not set
            firstSourceToSyncId = SOURCE_CALENDAR;
        }
        sourceToSync.push_back(APPOINTMENTS_NAME);
        nCheckedSources++;
        ((CuiDlg*)AfxGetMainWnd())->getSourceListCtrl().setState(SOURCE_CALENDAR, ITEM_STATE_TO_SYNC);
    }

    if(checkTasks.GetCheck() == BST_CHECKED) {
        if(firstSourceToSyncId == -1) {             //not set
            firstSourceToSyncId = SOURCE_TASKS;
        }
        sourceToSync.push_back(TASKS_NAME);
        nCheckedSources++;
        ((CuiDlg*)AfxGetMainWnd())->getSourceListCtrl().setState(SOURCE_TASKS, ITEM_STATE_TO_SYNC);
    }

    #if defined(WIN32_PLATFORM_PSPC)
    if(checkNotes.GetCheck() == BST_CHECKED) {
        if(firstSourceToSyncId == -1) {            //not set
            firstSourceToSyncId = SOURCE_NOTES;

⌨️ 快捷键说明

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