syncsettingsadvanced.cpp
来自「funambol window mobile客户端源代码」· C++ 代码 · 共 763 行 · 第 1/2 页
CPP
763 行
/*
* 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".
*/
// SyncSettingsAdvanced.cpp : implementation file
//
#include "stdafx.h"
#include "SyncSettingsAdvanced.h"
#include "pim/ClientSettings.h"
#include "pim/maincpp.h"
#include "processUtils.h"
#include "tpcshell.h" // for SHSendBackToFocusWindow
// CSyncSettingsAdvanced dialog
static bool showNoteSource = false;
static bool showBriefcaseSource = false;
IMPLEMENT_DYNAMIC(CSyncSettingsAdvanced, CDialog)
CSyncSettingsAdvanced::CSyncSettingsAdvanced(CWnd* pParent /*=NULL*/)
: CDialog(CSyncSettingsAdvanced::IDD, pParent)
{
// Just to store the local resources handle...
localResource = getLocalizationUtils()->getLocaleResource();
}
CSyncSettingsAdvanced::~CSyncSettingsAdvanced()
{
}
BEGIN_MESSAGE_MAP(CSyncSettingsAdvanced, CDialog)
#ifdef WIN32_PLATFORM_WFSP
ON_MESSAGE(WM_HOTKEY,&CSyncSettingsAdvanced::OnHotkey)
#endif
ON_WM_CTLCOLOR()
ON_WM_VSCROLL()
ON_WM_SIZE()
#if defined(WIN32_PLATFORM_PSPC)
ON_BN_SETFOCUS(IDC_ENCRYPTION, &CSyncSettingsAdvanced::OnBnSetfocusEncryption)
ON_EN_SETFOCUS(IDC_EDIT_MAIL, &CSyncSettingsAdvanced::OnEnSetfocusEditMail)
ON_EN_SETFOCUS(IDC_EDIT_CONTACT, &CSyncSettingsAdvanced::OnEnSetfocusEditContact)
ON_EN_SETFOCUS(IDC_EDIT_CALENDAR, &CSyncSettingsAdvanced::OnEnSetfocusEditCalendar)
ON_EN_SETFOCUS(IDC_EDIT_TASK, &CSyncSettingsAdvanced::OnEnSetfocusEditTask)
ON_EN_SETFOCUS(IDC_EDIT_NOTE, &CSyncSettingsAdvanced::OnEnSetfocusEditNote)
ON_EN_SETFOCUS(IDC_EDIT_BRIEFCASE, &CSyncSettingsAdvanced::OnEnSetfocusEditBriefcase)
ON_BN_SETFOCUS(IDC_RADIO_CONTACT_SIF, &CSyncSettingsAdvanced::OnBnSetfocusRadioContactSif)
ON_BN_SETFOCUS(IDC_RADIO_CONTACT_VCARD, &CSyncSettingsAdvanced::OnBnSetfocusRadioContactVcard)
ON_BN_SETFOCUS(IDC_RADIO_CALENDAR_SIF, &CSyncSettingsAdvanced::OnBnSetfocusRadioCalendarSif)
ON_BN_SETFOCUS(IDC_RADIO_CALENDAR_VCARD,&CSyncSettingsAdvanced::OnBnSetfocusRadioCalendarVcard)
ON_BN_SETFOCUS(IDC_RADIO_TASK_SIF, &CSyncSettingsAdvanced::OnBnSetfocusRadioTaskSif)
ON_BN_SETFOCUS(IDC_RADIO_TASK_VCARD, &CSyncSettingsAdvanced::OnBnSetfocusRadioTaskVcard)
ON_BN_SETFOCUS(IDC_RADIO_NOTE_SIF, &CSyncSettingsAdvanced::OnBnSetfocusRadioNoteSif)
ON_BN_SETFOCUS(IDC_RADIO_NOTE_VCARD, &CSyncSettingsAdvanced::OnBnSetfocusRadioNoteVcard)
#endif
END_MESSAGE_MAP()
void CSyncSettingsAdvanced::DoDataExchange(CDataExchange* pDX)
{
DDX_Control(pDX, IDC_ENCRYPTION, checkEncryption);
DDX_Control(pDX, IDC_EDIT_MAIL, textEmail);
DDX_Control(pDX, IDC_EDIT_CONTACT, textContact);
DDX_Control(pDX, IDC_EDIT_CALENDAR, textCalendar);
DDX_Control(pDX, IDC_EDIT_TASK, textTask);
DDX_Control(pDX, IDC_EDIT_BRIEFCASE, textBriefcase);
DDX_Control(pDX, IDC_RADIO_CALENDAR_SIF, radioCalendarSIF);
DDX_Control(pDX, IDC_RADIO_CALENDAR_VCARD, radioCalendarVCard);
DDX_Control(pDX, IDC_RADIO_CONTACT_SIF, radioContactSIF);
DDX_Control(pDX, IDC_RADIO_CONTACT_VCARD, radioContactVCard);
DDX_Control(pDX, IDC_RADIO_TASK_SIF, radioTaskSIF);
DDX_Control(pDX, IDC_RADIO_TASK_VCARD, radioTaskVCard);
#if defined(WIN32_PLATFORM_PSPC)
DDX_Control(pDX, IDC_EDIT_NOTE, textNotes);
DDX_Control(pDX, IDC_RADIO_NOTE_SIF, radioNoteSIF);
DDX_Control(pDX, IDC_RADIO_NOTE_VCARD, radioNoteVCard);
#endif
CDialog::DoDataExchange(pDX);
}
BOOL CSyncSettingsAdvanced::OnInitDialog(){
CString s1;
s1.LoadString(localResource, IDS_ADVANCED_SETTINGS);
SetWindowText(s1);
CDialog::OnInitDialog();
// create 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));
// set menubar
ZeroMemory(&dlgCommandBar, sizeof(SHMENUBARINFO));
dlgCommandBar.cbSize = sizeof(SHMENUBARINFO);
dlgCommandBar.hwndParent = this->GetSafeHwnd();
dlgCommandBar.dwFlags = SHCMBF_HMENU;
dlgCommandBar.nToolBarId = IDM_OKCANCEL;
#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;
}
//
// Manage the vertical scrolling-bar
//
GetWindowRect(&dlgRect);
scrollbarPosition = 0; // reset bar position
// Get the position of the bottom object of the dialog,
// the max scrollbar height is derived from this.
// *** NOTE: CHANGE IT IF THE OBJECT POSITION CHANGES! ***
CRect bottomObjectRect;
#if defined(WIN32_PLATFORM_PSPC)
radioNoteVCard.GetWindowRect(&bottomObjectRect);
#else
radioTaskVCard.GetWindowRect(&bottomObjectRect);
#endif
// 5 = some space
dlgMaxHeight = bottomObjectRect.bottom - dlgRect.top + 5;
// Set all scrollbar parameters
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_ALL; // SIF_ALL = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS;
si.nMin = 0;
si.nMax = dlgMaxHeight;
si.nPage = dlgRect.Height();
si.nPos = 0;
SetScrollInfo(SB_VERT, &si, TRUE);
// load string resources
s1.LoadString(localResource, IDS_SECURITY);
SetDlgItemText(IDC_SYNC_STATIC_SECURITY, s1);
GetDlgItem(IDC_SYNC_STATIC_SECURITY)->SetFont(&fontBold);
s1.LoadString(localResource, IDS_ENABLE_ENCRYPTION);
SetDlgItemText(IDC_ENCRYPTION, s1);
// set ppc header
#if defined(WIN32_PLATFORM_PSPC)
s1.LoadString(localResource, IDS_ADVANCED_SETTINGS);
SetDlgItemText(IDC_HEADER_STATIC, s1);
GetDlgItem(IDC_HEADER_STATIC)->SetFont(&fontBold);
#endif
s1.LoadString(localResource, IDS_REMOTENAME);
SetDlgItemText(IDC_REMOTE_NAMES, s1);
GetDlgItem(IDC_REMOTE_NAMES)->SetFont(&fontBold);
s1.LoadString(localResource, IDS_EMAIL);
SetDlgItemText(IDC_SYNC_EMAIL, s1);
s1.LoadString(localResource, IDS_CONTACTS);
SetDlgItemText(IDC_SYNC_CONTACT, s1);
s1.LoadString(localResource, IDS_CALENDAR);
SetDlgItemText(IDC_SYNC_CALENDAR, s1);
s1.LoadString(localResource, IDS_TASKS);
SetDlgItemText(IDC_SYNC_TASK, s1);
ClientSettings* cs = getRegConfig();
showNoteSource = cs->getBrandingParams().getShowNoteSource();
showBriefcaseSource = cs->getBrandingParams().getShowBriefcaseSource();
//if(!(getRegConfig()->getIsPortal())){
if (showNoteSource) {
// Normal build
#if defined(WIN32_PLATFORM_PSPC)
s1.LoadString(localResource, IDS_NOTES);
SetDlgItemText(IDC_SYNC_NOTE, s1);
#endif
} else {
#if defined(WIN32_PLATFORM_PSPC)
GetDlgItem(IDC_SYNC_NOTE)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_SYNC_NOTE_BOX)->ShowWindow(SW_HIDE);
radioNoteSIF.ShowWindow(SW_HIDE);
radioNoteVCard.ShowWindow(SW_HIDE);
#endif
}
if (showBriefcaseSource) {
s1.LoadString(localResource, IDS_BRIEFCASE);
SetDlgItemText(IDC_SYNC_BRIEFCASE, s1);
}
else{
GetDlgItem(IDC_SYNC_BRIEFCASE)->ShowWindow(SW_HIDE);
}
// 'Data Format' section
s1.LoadString(localResource, IDS_DATA_FORMAT);
SetDlgItemText(IDC_DATA_FORMAT, s1);
GetDlgItem(IDC_DATA_FORMAT)->SetFont(&fontBold);
s1.LoadString(localResource, IDS_CONTACTS); SetDlgItemText(IDC_SYNC_CONTACT_BOX, s1);
s1.LoadString(localResource, IDS_CALENDAR); SetDlgItemText(IDC_SYNC_CALENDAR_BOX, s1);
s1.LoadString(localResource, IDS_TASKS); SetDlgItemText(IDC_SYNC_TASK_BOX, s1);
s1.LoadString(localResource, IDS_SETTCONT_FORMAT1); SetDlgItemText(IDC_RADIO_CONTACT_SIF, s1);
s1.LoadString(localResource, IDS_SETTCONT_FORMAT2); SetDlgItemText(IDC_RADIO_CONTACT_VCARD, s1);
s1.LoadString(localResource, IDS_SETTCALE_FORMAT1); SetDlgItemText(IDC_RADIO_CALENDAR_SIF, s1);
s1.LoadString(localResource, IDS_SETTCALE_FORMAT2); SetDlgItemText(IDC_RADIO_CALENDAR_VCARD, s1);
s1.LoadString(localResource, IDS_SETTTASK_FORMAT1); SetDlgItemText(IDC_RADIO_TASK_SIF, s1);
s1.LoadString(localResource, IDS_SETTTASK_FORMAT2); SetDlgItemText(IDC_RADIO_TASK_VCARD, s1);
#if defined(WIN32_PLATFORM_PSPC)
s1.LoadString(localResource, IDS_NOTES); SetDlgItemText(IDC_SYNC_NOTE_BOX, s1);
s1.LoadString(localResource, IDS_SETTNOTE_FORMAT1); SetDlgItemText(IDC_RADIO_NOTE_SIF, s1);
s1.LoadString(localResource, IDS_SETTNOTE_FORMAT2); SetDlgItemText(IDC_RADIO_NOTE_VCARD, s1);
#endif
// read settings from Registry
//ClientSettings* cs = getRegConfig();
// *** not used ***
// Encryption is a property of every source. At the moment every source is
// is encrypted or not at the same time. So the check for the encryption is made
// only on a source that is contact
//
const char* encr = getRegConfig()->getWinSyncSourceConfig("contact")->getEncryption();
bool enc = false;
if (strcmp(encr, "des") == 0)
enc = true;
if(enc){
checkEncryption.SetCheck(BST_CHECKED);
}
else{
checkEncryption.SetCheck(BST_UNCHECKED);
}
s1 = cs->getWinSyncSourceConfig("mail")->getURI();
SetDlgItemText(IDC_EDIT_MAIL, s1);
s1 =cs->getWinSyncSourceConfig("contact")->getURI();
SetDlgItemText(IDC_EDIT_CONTACT, s1);
s1 =cs->getWinSyncSourceConfig("calendar")->getURI();
SetDlgItemText(IDC_EDIT_CALENDAR, s1);
s1 =cs->getWinSyncSourceConfig("task")->getURI();
SetDlgItemText(IDC_EDIT_TASK, s1);
// if(!(getRegConfig()->getIsPortal())){
if (showNoteSource) {
#if defined(WIN32_PLATFORM_PSPC)
s1 = cs->getWinSyncSourceConfig("note")->getURI();
SetDlgItemText(IDC_EDIT_NOTE, s1);
#endif
} else {
#if defined(WIN32_PLATFORM_PSPC)
GetDlgItem(IDC_EDIT_NOTE)->ShowWindow(SW_HIDE);
#endif
}
if (showBriefcaseSource) {
s1 = cs->getWinSyncSourceConfig("briefcase")->getURI();
SetDlgItemText(IDC_EDIT_BRIEFCASE,s1 );
}else{
GetDlgItem(IDC_EDIT_BRIEFCASE)->ShowWindow(SW_HIDE);
}
if(cs->getWinSyncSourceConfig("contact")->getUseSif() == "1"){
radioContactSIF.SetCheck(BST_CHECKED);
radioContactVCard.SetCheck(BST_UNCHECKED);
}else{
radioContactVCard.SetCheck(BST_CHECKED);
radioContactSIF.SetCheck(BST_UNCHECKED);
}
if(cs->getWinSyncSourceConfig("calendar")->getUseSif() == "1"){
radioCalendarSIF.SetCheck(BST_CHECKED);
radioCalendarVCard.SetCheck(BST_UNCHECKED);
}else{
radioCalendarVCard.SetCheck(BST_CHECKED);
radioCalendarSIF.SetCheck(BST_UNCHECKED);
}
if(cs->getWinSyncSourceConfig("task")->getUseSif() == "1"){
radioTaskSIF.SetCheck(BST_CHECKED);
radioTaskVCard.SetCheck(BST_UNCHECKED);
}else{
radioTaskVCard.SetCheck(BST_CHECKED);
radioTaskSIF.SetCheck(BST_UNCHECKED);
}
#if defined(WIN32_PLATFORM_PSPC)
if(cs->getWinSyncSourceConfig("note")->getUseSif() == "1"){
radioNoteSIF.SetCheck(BST_CHECKED);
radioNoteVCard.SetCheck(BST_UNCHECKED);
}else{
radioNoteVCard.SetCheck(BST_CHECKED);
radioNoteSIF.SetCheck(BST_UNCHECKED);
}
#endif
#ifdef WIN32_PLATFORM_WFSP
// override back key
LPARAM lparam = MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
SHMBOF_NODEFAULT | SHMBOF_NOTIFY);
::SendMessage(dlgCommandBar.hwndMB, SHCMBM_OVERRIDEKEY, VK_TBACK, lparam);
#endif
return FALSE;
}
/**
* Save settings to registry
*/
afx_msg void CSyncSettingsAdvanced::OnOK(){
ClientSettings* cs = getRegConfig();
BOOL dirtyFlag = FALSE;
if(checkStartSync()){
CDialog::OnOK();
}
// Encryption is disabled
if(checkEncryption.GetCheck() == BST_CHECKED) {
if(strcmp(cs->getConfigSourcesParameter("mail","encryption"),"des") != 0){
cs->setConfigSourcesParameter("mail","encryption","des");
dirtyFlag = TRUE;
}
if(strcmp(cs->getConfigSourcesParameter("calendar","encryption"),"des") != 0){
cs->setConfigSourcesParameter("calendar","encryption","des");
dirtyFlag = TRUE;
}
if(strcmp(cs->getConfigSourcesParameter("contact","encryption"),"des") != 0){
cs->setConfigSourcesParameter("contact","encryption","des");
dirtyFlag = TRUE;
}
if(strcmp(cs->getConfigSourcesParameter("task","encryption"),"des") != 0){
cs->setConfigSourcesParameter("task","encryption","des");
dirtyFlag = TRUE;
}
if(strcmp(cs->getConfigSourcesParameter("briefcase","encryption"),"des") != 0){
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?