📄 recoversettings.cpp
字号:
//refreshSyncType();
}
void CRecoverSettings::OnBnClickedRecoverCalendar()
{
EnableRecoverButton(isCheckboxChecked());
//refreshSyncType();
}
void CRecoverSettings::OnBnClickedRecoverContacts()
{
EnableRecoverButton(isCheckboxChecked());
//refreshSyncType();
}
void CRecoverSettings::OnBnClickedRecoverTasks()
{
EnableRecoverButton(isCheckboxChecked());
//refreshSyncType();
}
void CRecoverSettings::OnBnClickedRecoverBriefcase()
{
EnableRecoverButton(isCheckboxChecked());
//refreshSyncType();
}
bool CRecoverSettings::isCheckboxChecked()
{
bool value = false;
value = (checkContacts.GetCheck() == BST_CHECKED) ||
(checkCalendar.GetCheck() == BST_CHECKED) ||
(checkTasks.GetCheck() == BST_CHECKED) ||
(checkBriefcase.GetCheck() == BST_CHECKED) ||
(checkMail.GetCheck() == BST_CHECKED);
#if defined(WIN32_PLATFORM_PSPC)
value |= (checkNotes.GetCheck() == BST_CHECKED);
#endif
return value;
}
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
void CRecoverSettings::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
{
int resId;
CString s1,s2;
switch(DRA::GetDisplayMode())
{
case DRA::Landscape:
resId = IDD_UI_RECOVER_WIDE; break;
case DRA::Portrait:
resId = IDD_UI_RECOVER; break;
case DRA::Square:
resId = IDD_UI_RECOVER_SQUARE; break;
default:
resId = IDD_UI_BRIEFCASE; break;
};
// If the resource ID is not changed, it's useless to re-layout the dialog.
// This helps also to keep the correct strings if cleanup is running or not.
if (oldResId == resId) {
return;
}
DRA::RelayoutDialog( AfxGetInstanceHandle(), this->m_hWnd, MAKEINTRESOURCE(resId));
oldResId = resId;
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);
// for cleanup
if (cleanupStarted) s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_CLEANUP_IN_PROG);
else s1 = L"";
SetDlgItemText(IDC_CLEANUP, s1);
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
#if defined(WIN32_PLATFORM_PSPC)
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECOVER_ITEMS); SetDlgItemText(IDC_RECOVER_STATIC, s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_CLEANUP_TITLE); SetDlgItemText(IDC_RECOVER_STATIC_TITLE, s1);
GetDlgItem(IDC_RECOVER_STATIC)->SetFont(&fontBold);
GetDlgItem(IDC_RECOVER_STATIC_TITLE)->SetFont(&fontBold);
#endif
}
#endif
wstring getCommandLine(vector<const wchar_t*> &sources) {
wstring sourceList;
vector<const wchar_t*>::iterator sourcesIterator;
int i = 1;
for (sourcesIterator = sources.begin();
sourcesIterator != sources.end();
sourcesIterator++) {
sourceList.append(*sourcesIterator);
if (sources.size() - i != 0) {
sourceList.append(TEXT(","));
}
i++;
}
return sourceList;
}
int checkRefreshFromServer(HWND wndUI, vector<const wchar_t*> &sources, BOOL cleanup) {
bool isEmail = false;
wstring sourceList;
int i = 1, ret = 0;
wchar_t t[512];
vector<const wchar_t*>::iterator sourcesIterator;
for (sourcesIterator = sources.begin();
sourcesIterator != sources.end();
sourcesIterator++) {
sourceList.append(getFriendlyName(*sourcesIterator));
if(wcscmp( TEXT("mail") , *sourcesIterator ) == 0 ){
isEmail = true;
}
if (sources.size() - i == 1) {
sourceList.append(TEXT(" "));
sourceList.append(getLocalizationUtils()->getLocalizationString(IDS_AND));
sourceList.append(TEXT(" "));
} else if (sources.size() - i != 0) {
sourceList.append(TEXT(", "));
}
i++;
}
if (cleanup) {
wsprintf(t, getLocalizationUtils()->getLocalizationString(IDS_CLEANUP_MSG),
sourceList.c_str());
} else {
wsprintf(t, getLocalizationUtils()->getLocalizationString(IDS_RS_ARMSG1),
sourceList.c_str());
}
wstring message = t;
//if(cleanup && isEmail){
// message.append(getLocalizationUtils()->getLocalizationString(IDS_CLEANUP_MSG2));
//}
if(cleanup){
message.append(getLocalizationUtils()->getLocalizationString(IDS_CLEANUP_MSG3));
}
HwndFunctions::closePreviousMsgBox();
int val = TimedMessageBox(wndUI, message.c_str(), getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT),
MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND, ASK_REFRESH_TIMEOUT * 1000); // default ASK_TIMEOUT = 10
if (val == IDYES) {
LOG.debug("User said yes to delete local %S and refresh.", sourceList.c_str());
}
else {
LOG.debug("User said no to delete local %S and refresh." , sourceList.c_str());
ret = -1;
}
return ret;
}
/**
* Message used after the clean up process
*/
int endCleanUpProcess(HWND wndUI, vector<const wchar_t*> &sources) {
wchar_t t[512];
int i = 1;
wstring sourceList;
vector<const wchar_t*>::iterator sourcesIterator;
for (sourcesIterator = sources.begin();
sourcesIterator != sources.end();
sourcesIterator++) {
sourceList.append(getFriendlyName(*sourcesIterator));
if (sources.size() - i == 1) {
sourceList.append(TEXT(" "));
sourceList.append(getLocalizationUtils()->getLocalizationString(IDS_AND));
sourceList.append(TEXT(" "));
} else if (sources.size() - i != 0) {
sourceList.append(TEXT(", "));
}
i++;
}
wsprintf(t, getLocalizationUtils()->getLocalizationString(IDS_CLEANUP_COMPLETE_MSG),
sourceList.c_str());
HwndFunctions::closePreviousMsgBox();
int val = TimedMessageBox(wndUI, t, getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT),
MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND, ASK_REFRESH_TIMEOUT * 1000); // default ASK_TIMEOUT = 10
return 0;
}
void CRecoverSettings::OnLbnSelchangeRecoverListSynctype(){
ClientSettings* cs = getRegConfig();
// if replace server data is selected
if(lstSyncType.GetCurSel() == 1){
checkMail.SetCheck(BST_UNCHECKED);
checkMail.EnableWindow(FALSE);
}
else{
if( strcmp(cs->getConfigSourcesParameter("mail", "sync"),"none") &&
doesFunambolAccountExist())
checkMail.EnableWindow(TRUE);
}
}
HBRUSH CRecoverSettings::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) {
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// set ppc header text color
#if defined(WIN32_PLATFORM_PSPC)
if(pWnd->GetDlgCtrlID() == IDC_RECOVER_STATIC_TITLE) {
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(PPC_HEADER_TEXT_COLOR);
}
#endif
return hbr;
}
/**
* It disables all the checkbox to avoid they are pressed when the
* cleanup is in progress
*/
void CRecoverSettings::disableCheckbox() {
checkContacts.EnableWindow(FALSE);
checkCalendar.EnableWindow(FALSE);
checkTasks.EnableWindow(FALSE);
checkBriefcase.EnableWindow(FALSE);
checkMail.EnableWindow(FALSE);
#if defined(WIN32_PLATFORM_PSPC)
checkNotes.EnableWindow(FALSE);
#endif
}
void CRecoverSettings::enableCheckbox() {
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()){
if (!showBriefcaseSource) {
checkBriefcase.EnableWindow(FALSE);
checkBriefcase.ShowWindow(SW_HIDE);
}
if (!showNoteSource) {
#if defined(WIN32_PLATFORM_PSPC)
checkNotes.EnableWindow(FALSE);
checkNotes.ShowWindow(SW_HIDE);
#endif
}
}
void CRecoverSettings::OnPaint() {
// Set the cursor if cleanup is running or not: we could have switched to
// another window, so we set again the cursor.
if (cleanupStarted) SetCursor(LoadCursor(NULL, IDC_WAIT ));
else SetCursor(LoadCursor(NULL, IDC_ARROW));
CDialog::OnPaint();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -