⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customsyncclient.cpp

📁 funambol windows mobile plugin source code, the source code is taken from the funambol site
💻 CPP
字号:
/*
 * 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 General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 * 02111-1307  USA
 */
#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;

    //
    // 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) {
              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), getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT),
                        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");
        }
        else {
            addComma = FALSE;
            addAnd = FALSE;

            for (unsigned int k = 0; k < slowNames.size(); k++) {

                if (addComma) {
                    list += TEXT(", ");
                }
                if (addAnd) {
                    list += TEXT(" and ");
                }

                list += getFriendlyName(slowNames[k]);

                if (k == slowNames.size() - 2) {
                    addComma = FALSE;
                    addAnd = TRUE;
                }
                else {
                    addComma = TRUE;
                    addAnd = FALSE;
                }
            }
        }

        msg += list + getLocalizationUtils()->getLocalizationString(IDS_CSC_MSG1_2);

        HwndFunctions::closePreviousMsgBox();
        r = TimedMessageBox(NULL, msg.c_str(), getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT),
                            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(), getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT),
                                 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -