📄 mailsettings.cpp
字号:
case 6: value=250;break;
case 7: value=-1;break;
}
if(cs->mailssconfig->getAttachSize() != value){
cs->mailssconfig->setAttachSize(value);
cs->setDirty(CS_DIRTY_SOURCE_MAIL);
dirtyFlag = TRUE;
}
// attachments
if(checkAttachments.GetCheck() == BST_CHECKED){
if(cs->mailssconfig->getBodySize() != -1){
cs->mailssconfig->setBodySize(-1);
cs->setDirty(CS_DIRTY_SOURCE_MAIL);
dirtyFlag = TRUE;
}
}
else {
if(cs->mailssconfig->getBodySize() != 1){
cs->mailssconfig->setBodySize(1);
cs->setDirty(CS_DIRTY_SOURCE_MAIL);
dirtyFlag = TRUE;
}
}
if (ENABLE_CHECK_FOR_FILTER) {
// filter
if(checkFilter.GetCheck() == BST_CHECKED){
if(cs->getEmailFilter() != "1") {
cs->setEmailFilter("1");
cs->setConfigSyncDirty(CP_DIRTY_EMAIL_FILTER_STATUS); // For config sync
cs->setDirty(CS_DIRTY_ROOT_CONFIG);
dirtyFlag = TRUE;
}
}
else {
if(cs->getEmailFilter() != "0") {
cs->setEmailFilter("0");
cs->setConfigSyncDirty(CP_DIRTY_EMAIL_FILTER_STATUS); // For config sync
cs->setDirty(CS_DIRTY_ROOT_CONFIG);
dirtyFlag = TRUE;
}
}
}
// Save to registry.
if(dirtyFlag){
cs->saveDirty();
}
if (ENABLE_CHECK_FOR_FILTER) {
if (cs->getConfigSyncDirty() != 0) {
// Start a config sync.
// Note: here we check the dirty flag, because the email address or
// visible name could have been modified in advanced dialog.
if (startConfigSync() == 0) {
// Dialog is stuck with waiting cursor.
// Will be re-enabled when sync has finished, calling OnMsgConfigSyncEnded().
return;
}
}
}
SetCursor(LoadCursor(NULL, IDC_ARROW));
CDialog::OnOK();
}
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
void CMailSettings::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
{
//int displayMode = DRA::GetDisplayMode();
int resId;
switch(DRA::GetDisplayMode())
{
case DRA::Landscape:
resId = IDD_UI_MAIL_WIDE; break;
case DRA::Portrait:
resId = IDD_UI_MAIL; break;
case DRA::Square:
resId = IDD_UI_MAIL_SQUARE; break;
default:
resId = IDD_UI_MAIL; break;
};
DRA::RelayoutDialog( AfxGetInstanceHandle(), this->m_hWnd, MAKEINTRESOURCE(resId));
LoadStringResources();
// Repositioning the Alert label at the bottom
CRect clientRect, alertRect;
GetClientRect(&clientRect);
CWnd* alertLabel = GetDlgItem(IDC_ALERT);
if (alertLabel) {
alertLabel->GetWindowRect(&alertRect);
int x = 5;
int y = clientRect.Height() - alertRect.Height();
int cx = clientRect.Width() - 5; // Max value
int cy = alertRect.Height(); // No change
alertLabel->SetWindowPos(&CWnd::wndTop, x, y, cx, cy, SWP_NOZORDER);
}
}
#endif
void CMailSettings::LoadStringResources(){
CString s1;
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_ADVANCED_SETTINGS); linkAdvanced.setText(s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_SYNCTYPE); SetDlgItemText(IDC_SETTMAIL_STATIC_SYNCTYPE, s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_ATTACHMENTS); SetDlgItemText(IDC_MAIL_CHECK_ATTACHMENTS, s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_DOWNLOAD); SetDlgItemText(IDC_MAIL_STATIC_DOWNLOAD, s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_SETTMAIL_BUTFOLDERS); SetDlgItemText(IDC_SETTMAIL_BUTFOLDERS, s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_SETTMAIL_BUTFILTER); SetDlgItemText(IDC_SETTMAIL_BUTFILTER, s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_SETTMAIL_BUTACCOUNT); SetDlgItemText(IDC_SETTMAIL_BUTACCOUNT, s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_CHECKING_CONFIG); SetDlgItemText(IDC_ALERT, s1);
if (ENABLE_CHECK_FOR_FILTER) {
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_MAILS_FILTER_MYCONTACTS); SetDlgItemText(IDC_MAIL_CHECK_FILTER, s1);
}
#if defined(WIN32_PLATFORM_PSPC)
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_MAIL_SETTINGS); SetDlgItemText(IDC_HEADER_STATIC, s1);
#endif
}
void CMailSettings::OnBnClickedMailLinkAdvanced()
{
CMailSettingsAdvanced wndMailAdvanced;
INT_PTR result = wndMailAdvanced.DoModal();
}
// capture pressing of 'Advanced' link
BOOL CMailSettings::PreTranslateMessage(MSG* pMsg){
bool bProcessed =false;
if(pMsg->message == WM_KEYDOWN){
if(pMsg->wParam == VK_RETURN){
if(GetFocus()->GetSafeHwnd() == linkAdvanced.GetSafeHwnd()){
bProcessed = true;
OnBnClickedMailLinkAdvanced();
}
}
};
if(bProcessed)
return TRUE;
else
return CDialog::PreTranslateMessage(pMsg);
}
HBRUSH CMailSettings::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_HEADER_STATIC) {
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(PPC_HEADER_TEXT_COLOR);
}
#endif
if(pWnd->GetDlgCtrlID() == IDC_ALERT) {
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(ALERT_COLOR);
}
return hbr;
}
int CMailSettings::startConfigSync() {
// First of all, check the syncmode. If "none" don't do anything.
ClientSettings* cs = getRegConfig();
SyncSourceConfig* ssc = cs->getSyncSourceConfig("config");
if (!ssc) {
LOG.error("Config Syncsource not existing, aborting config sync.");
return 1;
}
if (!strcmp(ssc->getSync(), "none")) {
LOG.debug("Config syncmode is 'none', aborting config sync.");
return 1;
}
// Disable the UI.
SetCursor(LoadCursor(NULL, IDC_WAIT));
enableUIObjects(false);
CString s1;
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_CHECKING_CONFIG);
GetDlgItem(IDC_ALERT)->ShowWindow(SW_SHOW);
SetDlgItemText(IDC_ALERT, s1);
// Start the config sync, in a separate thread.
HWND thisWindow = GetSafeHwnd();
if ( !CreateThread(NULL, 0, configWorker, (LPVOID)thisWindow, 0, NULL) ) {
LOG.error("Error creating configWorker thread.");
return 1;
}
return 0; // Dialog is stuck with the waiting cursor here...
}
void CMailSettings::enableUIObjects(bool enable) {
HWND thisWnd = this->GetSafeHwnd();
EnableButton(thisWnd, 0, enable); // '0' is the ID of the 'menu' on the right.
EnableButton(thisWnd, IDOK, enable);
lstMailSince.EnableWindow(enable);
lstMsgSize.EnableWindow(enable);
linkAdvanced.EnableWindow(enable);
checkAttachments.EnableWindow(enable);
if (ENABLE_CHECK_FOR_FILTER) {
checkFilter.EnableWindow(enable);
}
//lstSyncType.EnableWindow(enable);
#if defined(WIN32_PLATFORM_WFSP)
spinMailSince.EnableWindow(enable);
spinMsgSize.EnableWindow(enable);
//spinSyncType.EnableWindow(enable);
#endif
}
LRESULT CMailSettings::OnMsgConfigSyncEnded(WPARAM wparam, LPARAM lparam) {
bool isOldServer = false;
int exitcode = (int)wparam;
switch (exitcode) {
case 0: // OK
break;
case ERR_CONFIG_SOURCE_NOT_FOUND: // 2100 = "config" source not found on the Server.
// Silently catched in uiDlg::OnStartSyncEnded()
isOldServer = true;
break;
case 401:
case 402:
case 403:
// Msgbox is already displayed.
LOG.info("Authentication failed, code %d", exitcode);
break;
// case 404: should not happen (404 is catched and converted into code 2100)
default:
if (exitcode >= 2000) {
// Error msg already displayed -> uiDlg::OnStartSyncEnded()
LOG.error("Network error, code %d", exitcode);
}
else {
LOG.error("Generic error, code %d", exitcode);
}
break;
}
//
// We MUST not change the flag if Server didn't send a status 200 for EmailFilter.
//
if (!isOldServer) {
ClientSettings* cs = getRegConfig();
if (cs->getConfigSyncDirty() & CP_DIRTY_EMAIL_FILTER_STATUS) {
// Means that something went wrong, and the filterStatus
// was not updated on the Server. So return to the previous selection.
if (cs->getEmailFilter() == "0") {
cs->setEmailFilter("1");
}
else {
cs->setEmailFilter("0");
}
// Save the previous value, and warn the user.
cs->clearConfigSyncDirty(CP_DIRTY_EMAIL_FILTER_STATUS);
cs->setDirty(CS_DIRTY_ROOT_CONFIG);
cs->saveDirty();
TimedMessageBox(GetSafeHwnd(), TEXT("Email options could not be updated correctly. Check log for details."),
getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT),
MB_OK | MB_ICONHAND | MB_SETFOREGROUND, 10 * 1000);
}
}
// Re-enable UI dialog.
GetDlgItem(IDC_ALERT)->ShowWindow(SW_HIDE);
SetDlgItemText(IDC_ALERT, TEXT(""));
enableUIObjects(true);
SetCursor(LoadCursor(NULL, IDC_ARROW));
// Will go to main settings screen.
CDialog::OnOK();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -