syncsettings.cpp
来自「funambol window mobile客户端源代码」· C++ 代码 · 共 1,160 行 · 第 1/3 页
CPP
1,160 行
/*
* 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".
*/
// SyncSettings.cpp : implementation file
//
#include "stdafx.h"
#include "SyncSettings.h"
#include "PIMSettings.h"
#include "ContactSettings.h"
#include "CalendarSettings.h"
#include "TaskSettings.h"
#include "MailSettings.h"
#include "BriefcaseSettings.h"
#include "pim/ClientSettings.h"
#include "SyncSettingsAdvanced.h"
#include "SyncMethod.h"
#if defined(WIN32_PLATFORM_PSPC)
#include "NotesSettings.h"
#endif
#include "aygshell.h"
#include "pim/maincpp.h"
#include "pim/account.h"
// CSyncSettings dialog
#define ADVANCED_CONTACTS 1
#define ADVANCED_CALENDAR 2
#define ADVANCED_TASKS 4
#define ADVANCED_MAIL 8
#define ADVANCED_BRIEFCASE 16
#define ADVANCED_NOTES 32
#define ADVANCED_PIM 7 // 1 + 2 + 4
static bool showNoteSource = false;
static bool showBriefcaseSource = false;
static bool showAdvSettingMenu = false;
IMPLEMENT_DYNAMIC(CSyncSettings, CDialog)
CSyncSettings::CSyncSettings(CWnd* pParent /*=NULL*/)
: CDialog(CSyncSettings::IDD, pParent)
{
paddingVal = 100;
}
CSyncSettings::~CSyncSettings()
{
}
void CSyncSettings::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_SYNC_CONTACTS, checkContacts);
DDX_Control(pDX, IDC_SYNC_CALENDAR, checkCalendar);
DDX_Control(pDX, IDC_SYNC_TASKS, checkTasks);
DDX_Control(pDX, IDC_SYNC_MAIL, checkMail);
DDX_Control(pDX, IDC_SYNC_BRIEFCASE, checkBriefcase);
#if defined(WIN32_PLATFORM_PSPC)
DDX_Control(pDX, IDC_SYNC_NOTES, checkNotes);
#endif
DDX_Control(pDX, IDC_SYNC_BUTTON_MAIL, butMail);
DDX_Control(pDX, IDC_SYNC_BUTTON_PIM_OPTIONS, butPimOptions);
DDX_Control(pDX, IDC_SYNC_LINK_ADVANCED, linkAdvanced);
}
BEGIN_MESSAGE_MAP(CSyncSettings, CDialog)
#if defined(_DEVICE_RESOLUTION_AWARE)
ON_WM_SIZE()
#endif
ON_WM_CTLCOLOR()
ON_WM_PAINT()
ON_BN_SETFOCUS(IDC_SYNC_CONTACTS, &CSyncSettings::OnSetfocusSyncContacts)
ON_BN_SETFOCUS(IDC_SYNC_CALENDAR, &CSyncSettings::OnBnSetfocusSyncCalendar)
ON_BN_SETFOCUS(IDC_SYNC_TASKS, &CSyncSettings::OnBnSetfocusSyncTasks)
ON_BN_SETFOCUS(IDC_SYNC_MAIL, &CSyncSettings::OnBnSetfocusSyncMail)
ON_BN_SETFOCUS(IDC_SYNC_BRIEFCASE, &CSyncSettings::OnBnSetfocusSyncBriefcase)
ON_BN_SETFOCUS(IDC_SYNC_LINK_ADVANCED, &CSyncSettings::OnBnSetfocusSyncLinkAdvanced)
ON_WM_INITMENUPOPUP()
#if defined(WIN32_PLATFORM_PSPC)
ON_BN_SETFOCUS(IDC_SYNC_NOTES, &CSyncSettings::OnBnSetfocusSyncNotes)
#endif
ON_BN_CLICKED(IDC_SYNC_CONTACTS, &CSyncSettings::OnBnClickedSyncContacts)
ON_BN_CLICKED(IDC_SYNC_CALENDAR, &CSyncSettings::OnBnClickedSyncCalendar)
ON_BN_CLICKED(IDC_SYNC_TASKS, &CSyncSettings::OnBnClickedSyncTasks)
ON_BN_CLICKED(IDC_SYNC_MAIL, &CSyncSettings::OnBnClickedSyncMail)
ON_BN_CLICKED(IDC_SYNC_BRIEFCASE, &CSyncSettings::OnBnClickedSyncBriefcase)
//ON_COMMAND(IDADVANCED, &CSyncSettings::showAdvanced)
ON_BN_CLICKED(IDC_SYNC_BUTTON_MAIL, &CSyncSettings::OnClickedSyncButtonMail)
ON_BN_CLICKED(IDC_SYNC_BUTTON_BRIEFCASE, &CSyncSettings::OnClickedSyncButtonBriefcase)
ON_BN_CLICKED(IDC_SYNC_BUTTON_PIM_OPTIONS, &CSyncSettings::OnClickedSyncButtonPimOptions)
#if defined(WIN32_PLATFORM_PSPC)
ON_BN_CLICKED(IDC_SYNC_NOTES, &CSyncSettings::OnBnClickedSyncNotes)
ON_BN_CLICKED(IDC_SYNC_BUTTON_NOTES, &CSyncSettings::OnClickedSyncButtonNotes)
#endif
ON_BN_CLICKED(IDC_SYNC_LINK_ADVANCED, &CSyncSettings::OnBnClickedSyncLinkAdvanced)
ON_COMMAND(ID_EMAIL_OPTIONS, &CSyncSettings::OnEmailOptionsClicked)
ON_COMMAND(ID_PIM_OPTIONS, &CSyncSettings::OnPIMOptionsClicked)
ON_COMMAND(ID_SYNC_METHOD, &CSyncSettings::OnSyncMethodClicked)
ON_COMMAND(ID_MENU_ADVANCED, &CSyncSettings::OnAdvanced)
END_MESSAGE_MAP()
void CSyncSettings::OnInitMenuPopup(CMenu *pPopupMenu, UINT nIndex,BOOL bSysMenu)
{
if(checkMail.GetCheck()==BST_CHECKED){
pPopupMenu->EnableMenuItem(ID_EMAIL_OPTIONS,MF_ENABLED);
}else{
pPopupMenu->EnableMenuItem(ID_EMAIL_OPTIONS,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
}
bool flag = false;
if(checkContacts.GetCheck() == BST_CHECKED && !flag){
flag = true;
}
if(checkCalendar.GetCheck() == BST_CHECKED && !flag){
flag = true;
}
if(checkTasks.GetCheck() == BST_CHECKED && !flag){
flag = true;
}
if (showBriefcaseSource) {
if(checkBriefcase.GetCheck() == BST_CHECKED && !flag){
flag = true;
}
}
if (showNoteSource) {
#if defined(WIN32_PLATFORM_PSPC)
if(checkNotes.GetCheck() == BST_CHECKED && !flag){
flag = true;
}
#endif
}
/*
if(!(getRegConfig()->getIsPortal())){
if(checkBriefcase.GetCheck() == BST_CHECKED && !flag){
flag = true;
}
#if defined(WIN32_PLATFORM_PSPC)
if(checkNotes.GetCheck() == BST_CHECKED && !flag){
flag = true;
}
#endif
}
*/
if(flag){
pPopupMenu->EnableMenuItem(ID_PIM_OPTIONS,MF_ENABLED);
}else{
pPopupMenu->EnableMenuItem(ID_PIM_OPTIONS,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
}
}
// CSyncSettings message handlers
BOOL CSyncSettings::OnInitDialog()
{
CString s1;
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_SYNC_SETTINGS);
SetWindowText(s1);
CDialog::OnInitDialog();
butMail.ShowWindow(TRUE);
//butBriefcase.ShowWindow(TRUE);
butPimOptions.ShowWindow(TRUE);
#if defined(WIN32_PLATFORM_PSPC)
// butNotes.ShowWindow(TRUE);
#endif
ClientSettings* cs = getRegConfig();
showNoteSource = cs->getBrandingParams().getShowNoteSource();
showBriefcaseSource = cs->getBrandingParams().getShowBriefcaseSource();
showAdvSettingMenu = cs->getBrandingParams().getShowAdvSettingMenu();
ZeroMemory(&dlgCommandBar, sizeof(SHMENUBARINFO));
dlgCommandBar.cbSize = sizeof(SHMENUBARINFO);
dlgCommandBar.hwndParent = this->GetSafeHwnd();
dlgCommandBar.dwFlags = SHCMBF_HMENU;
if(showAdvSettingMenu){
dlgCommandBar.nToolBarId = IDM_SYNC_SETTINGS;
} else {
dlgCommandBar.nToolBarId = IDM_SYNC_SETTINGS_NO_ADV;
}
#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;
}
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));
// load strings
LoadStringResources();
GetDlgItem(IDC_SYNC_STATIC_ITEMS)->SetFont(&fontBold);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_ADVANCED_SETTINGS);
linkAdvanced.setText(s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_EMAIL_OPTIONS);
butMail.setText(s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_PIM_OPTIONS);
butPimOptions.setText(s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_SYNC_METHOD_ABB);
linkAdvanced.setText(s1);
int dim = s1.GetLength();
// Hide groupbox, it's used only to know the position for the bottom line
GetDlgItem(IDC_PIM_GROUPBOX)->ShowWindow(SW_HIDE);
if( strcmp(cs->getConfigSourcesParameter("contact","sync"), "none")){
checkContacts.SetCheck(BST_CHECKED);
}
else {
checkContacts.SetCheck(BST_UNCHECKED);
}
if(strcmp(cs->getConfigSourcesParameter("calendar","sync"), "none")) {
checkCalendar.SetCheck(BST_CHECKED);
}
else {
checkCalendar.SetCheck(BST_UNCHECKED);
}
checkTasks.EnableWindow(TRUE);
if( strcmp(cs->getConfigSourcesParameter("task","sync"), "none")){
checkTasks.SetCheck(BST_CHECKED);
}
else{
checkTasks.SetCheck(BST_UNCHECKED);
}
if (doesFunambolAccountExist()) {
// Funambol mail account exists
checkMail.EnableWindow(TRUE);
if( strcmp(cs->getConfigSourcesParameter("mail","sync"), "none")){
checkMail.SetCheck(BST_CHECKED);
}
else{
checkMail.SetCheck(BST_UNCHECKED);
butMail.EnableWindow(FALSE);
};
} else {
// Funambol mail account DOES NOT exist
checkMail.EnableWindow(FALSE);
butMail.EnableWindow(FALSE);
checkMail.SetCheck(BST_UNCHECKED);
}
if (showBriefcaseSource) {
checkBriefcase.EnableWindow(TRUE);
checkBriefcase.ShowWindow(SW_SHOW);
if( strcmp(cs->getConfigSourcesParameter("briefcase","sync"), "none"))
checkBriefcase.SetCheck(BST_CHECKED);
else
{
checkBriefcase.SetCheck(BST_UNCHECKED);
}
} else {
checkBriefcase.EnableWindow(FALSE);
checkBriefcase.SetCheck(BST_UNCHECKED);
checkBriefcase.ShowWindow(SW_HIDE);
}
if (showNoteSource) {
#if defined(WIN32_PLATFORM_PSPC)
checkNotes.EnableWindow(TRUE);
checkNotes.ShowWindow(SW_SHOW);
if( strcmp(cs->getConfigSourcesParameter("note","sync"), "none"))
checkNotes.SetCheck(BST_CHECKED);
else
{
checkNotes.SetCheck(BST_UNCHECKED);
}
} else {
checkNotes.EnableWindow(FALSE);
checkNotes.SetCheck(BST_UNCHECKED);
checkNotes.ShowWindow(SW_HIDE);
#endif
}
bool pimButFlag = false;
if(checkContacts.GetCheck() == BST_CHECKED && !pimButFlag){
pimButFlag = true;
}
if(checkCalendar.GetCheck() == BST_CHECKED && !pimButFlag){
pimButFlag = true;
}
if(checkTasks.GetCheck() == BST_CHECKED && !pimButFlag){
pimButFlag = true;
}
if (showBriefcaseSource) {
//if(!(getRegConfig()->getIsPortal())){
if(checkBriefcase.GetCheck() == BST_CHECKED && !pimButFlag){
pimButFlag = true;
}
}
if (showNoteSource) {
#if defined(WIN32_PLATFORM_PSPC)
if(checkNotes.GetCheck() == BST_CHECKED && !pimButFlag){
pimButFlag = true;
}
#endif
}
if (!pimButFlag){
butPimOptions.EnableWindow(FALSE);
}
source = TEXT("");
advanced = 0;
checkedSources = 0;
Invalidate();
UpdateWindow();
// 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;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?