customsyncclient.cpp
来自「funambol window mobile客户端源代码」· C++ 代码 · 共 172 行
CPP
172 行
/*
* 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".
*/
#include "pim/CustomSyncClient.h"
#include "event/ManageListener.h"
#include "notify/timed_msgbox.h"
#include "HwndFunctions.h"
#include "pim/Utils.h"
#include "localizationUtils.h"
#ifdef WIN32_PLATFORM_WFSP
#include "funresourcesp.h"
#endif
#ifdef WIN32_PLATFORM_PSPC
#include "funresourceppc.h"
#endif
#define ASK_SLOW_TIMEOUT_Q1 30
#define ASK_SLOW_TIMEOUT_Q2 30
CustomSyncClient::CustomSyncClient() {
}
CustomSyncClient::~CustomSyncClient() {
}
int CustomSyncClient::continueAfterPrepareSync() {
wstring msg, list;
wchar_t title[128];
wsprintf(title, TEXT("%s"), getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT));
//
// sourcename are the name of the source that are populated by the server.
// So all the sources that have to be synched
// nameOfSources are the sources populated by the client. they are the ones that
// are set for a recover sync
//
bool addComma = false, addAnd = false;
int ret = 0, r = 0;
vector<wstring> slowNames;
for (unsigned int j = 0; j < namesOfSources.size(); j++) {
// check if modes has enough elements
if(j < modes.size()){
if (modes[j] == 201 && sourcenames[j] != TEXT("config")) {
slowNames.push_back(sourcenames[j]);
}
}
}
if (slowNames.size() == 0) {
return 0;
}
if (slowNames.size() == 1 &&
slowNames[0] == TEXT("mail") &&
isMailInclusive) {
TimedMessageBox(NULL, getLocalizationUtils()->getLocalizationString(IDS_MAIL_INCLUSIVE),
title, MB_OK | MB_ICONQUESTION | MB_SETFOREGROUND,
ASK_SLOW_TIMEOUT_Q1 * 1000); // default ASK_TIMEOUT = 10
ret = -20;
LOG.info("Sync aborted because a mail slow sync instead of a one-way-server");
} else {
HwndFunctions::closePreviousMsgBox();
msg = getLocalizationUtils()->getLocalizationString(IDS_CSC_MSG1_1);
if (slowNames.size() > 3 && slowNames.size() == namesOfSources.size()) {
//list = TEXT("all items"); in german is empty
list = getLocalizationUtils()->getLocalizationString(IDS_ALL_ITEMS);
}
else {
list = getLocalizationUtils()->getLocalizationString(IDS_FOR);
addComma = FALSE;
addAnd = FALSE;
for (unsigned int k = 0; k < slowNames.size(); k++) {
if (addComma) {
list += TEXT(", ");
}
if (addAnd) {
list += TEXT(" ");
list += getLocalizationUtils()->getLocalizationString(IDS_AND);
list += TEXT(" ");
}
list += getFriendlyName(slowNames[k]);
if (k == slowNames.size() - 2) {
addComma = FALSE;
addAnd = TRUE;
}
else {
addComma = TRUE;
addAnd = FALSE;
}
}
list += TEXT(".");
}
msg += list + getLocalizationUtils()->getLocalizationString(IDS_CSC_MSG1_2);
HwndFunctions::closePreviousMsgBox();
r = TimedMessageBox(NULL, msg.c_str(), title,
MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND,
ASK_SLOW_TIMEOUT_Q1 * 1000);
if (r == IDYES) {
ret = 0;
}
else {
if (slowNames.size() != namesOfSources.size()) {
// Show reminder
msg = getLocalizationUtils()->getLocalizationString(IDS_CSC_MSG2_1);
msg += list + getLocalizationUtils()->getLocalizationString(IDS_CSC_MSG2_2) ;
HwndFunctions::closePreviousMsgBox();
int val = TimedMessageBox(NULL, msg.c_str(), title,
MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND,
ASK_SLOW_TIMEOUT_Q2 * 1000);
}
ret = -20;
LOG.info("Sync aborted by the user to avoid slow-sync: %ls", list.c_str());
}
}
return ret;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?