📄 recoversettings.cpp
字号:
/*
* 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".
*/
// 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"
#include "processUtils.h"
static BOOL cleanupStarted = false;
static bool showNoteSource = false;
static bool showBriefcaseSource = false;
static int checkRefreshFromServer(HWND wndUI, vector<const wchar_t*> &sources, BOOL cleanup);
static wstring getCommandLine(vector<const wchar_t*> &sources);
int endCleanUpProcess(HWND wndUI, vector<const wchar_t*> &sources);
static LOGFONT lf;
static HANDLE hMutex;
// CRecoverSettings dialog
void writeSourceForSlow(const wchar_t* value);
IMPLEMENT_DYNAMIC(CRecoverSettings, CDialog)
/**
* Parameters for the cleanup task
*/
class CleanUpParams {
public:
CDialog &wndRef;
vector<const wchar_t*> srcRef;
CuiDlg* mainDlg;
CleanUpParams(CDialog &wnd, vector<const wchar_t*> sources, CuiDlg* dlg) :
wndRef(wnd),srcRef(sources), mainDlg(dlg) {};
~CleanUpParams() {};
} ;
// Cleanup thread
static DWORD WINAPI cleanUpTask(LPVOID lpv);
CRecoverSettings::CRecoverSettings(CWnd* pParent /*=NULL*/)
: CDialog(CRecoverSettings::IDD, pParent)
{
oldResId = -1;
}
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_WM_ACTIVATE()
ON_LBN_SELCHANGE(IDC_RECOVER_LIST_SYNCTYPE, &CRecoverSettings::OnLbnSelchangeRecoverListSynctype)
ON_WM_CTLCOLOR()
ON_WM_PAINT()
END_MESSAGE_MAP()
/*void CRecoverSettings::OnActivate(UINT nState, CWnd* pWndOther,BOOL bMinimized ){
if(cleanupStarted){
pWndOther->GetDlgItem(IDC_CLEANUP)->ShowWindow(SW_SHOW);
}else{
pWndOther->GetDlgItem(IDC_CLEANUP)->ShowWindow(SW_HIDE);
}
}*/
// 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
// Hide the drop down list
lstSyncType.ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECOVER_STATIC_DIRECTION)->ShowWindow(SW_HIDE);
#if 0
// load string resources
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_SYNCTYPE2); lstSyncType.AddString(s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_SYNCTYPE3); lstSyncType.AddString(s1);
// add string for the cleanup only and set the cursor
lstSyncType.AddString(L"cleanup");
lstSyncType.SetCurSel(2);
#endif
s2.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_ITEMS); SetDlgItemText(IDC_RECOVER_STATIC, s2);
#if defined(WIN32_PLATFORM_PSPC)
s2.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_CLEANUP_TITLE); SetDlgItemText(IDC_RECOVER_STATIC_TITLE, s2);
#endif
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_BRIEFCASE); SetDlgItemText(IDC_RECOVER_BRIEFCASE, s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_DIRECTION); SetDlgItemText(IDC_RECOVER_STATIC_DIRECTION, s1);
// for cleanup
SetDlgItemText(IDC_CLEANUP, TEXT(""));
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_MAIL); SetDlgItemText(IDC_RECOVER_MAIL, s1);
//*******
#if 0
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_MAIL); s1+=" "; s2.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_EMAIL_SYNCTYPE);
s1+=s2;
SetDlgItemText(IDC_RECOVER_MAIL, s1);
#endif
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);
#if defined(WIN32_PLATFORM_PSPC)
GetDlgItem(IDC_RECOVER_STATIC_TITLE)->SetFont(&fontBold);
#endif
// check what sources are set to synctype none, and disable the checkboxes
ClientSettings* cs = getRegConfig();
showNoteSource = cs->getBrandingParams().getShowNoteSource();
showBriefcaseSource = cs->getBrandingParams().getShowBriefcaseSource();
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()){
if (!showBriefcaseSource) {
checkBriefcase.EnableWindow(FALSE);
checkBriefcase.ShowWindow(SW_HIDE);
}
if (!showNoteSource) {
#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();
#if defined(WIN32_PLATFORM_PSPC)
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_ITEMS); SetDlgItemText(IDC_RECOVER_STATIC, s1);
GetDlgItem(IDC_RECOVER_STATIC)->SetFont(&fontBold);
GetDlgItem(IDC_RECOVER_STATIC_TITLE)->SetFont(&fontBold);
#endif
return FALSE;
}
/**
* All the choiche are removed and remain only the one for the cleanup
* Actually should be the only used.
*/
void CRecoverSettings::OnOK(){
wstring command;
int nCheckedSources = 0;
int firstSourceToSyncId = -1;
vector<const wchar_t*> sourceToSync;
#if 0
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;
} else if(lstSyncType.GetCurSel() == 2) {
command += L"cleanup ";
mailToRecover = TRUE;
}
#endif
// put here only for the cleanup task
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -