亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? startsync.cpp

?? funambol windows mobile plugin source code, the source code is taken from the funambol site
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/*
 * 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
 */


// startsync.cpp - main module for the sync application
//

// Windows Header Files:
#include <windows.h>
#include <initguid.h>
#include <Notify.h>
#include <Pmpolicy.h>

#include "base/startcmd.h"
#include "base/util/utils.h"

#include "pim/SettingFunctions.h"
#include "pim/maincpp.h"
#include "notify/addresschange.h"
#include "pim/difftime.h"
#include "usernotify.h"
#include "base/Log.h"
#include "pushmessage.h"
#include "notify/util.h"
#include "notify/timed_msgbox.h"
#include "spds/constants.h"
#include "OTAConfigMessage.h"
#include "OTAConfigMessageHandler.h"
#include <cemapi.h>
#include "pim/utils.h"
#include <string>
#include "customization.h"
using namespace std;

//
// USE the pim/ClientSettings.h. THis must be shared with the same ClientSettings of the
// FunambolClient
//
#include "pim/ClientSettings.h"
#include "OutOfMemoryException.h"

#include "HwndFunctions.h"
#include "localizationUtils.h"

#define DIMCONF 128
#define DIM_PATH 256
#define NOT_RETURN_TO_MAIN_FORM -3
#define NO_SOURCES_FROM_TRANSPORT -12

#ifdef WIN32_PLATFORM_WFSP
#include "funresourcesp.h"
#endif
#ifdef WIN32_PLATFORM_PSPC
#include "funresourceppc.h"
#endif


#define PARAM_AVAILABLE         TEXT("available")
#define PARAM_REMOVENOTIF       TEXT("removeNotif")
#define PARAM_SCHEDULE          TEXT("schedule")
#define PARAM_CRADLE            TEXT("cradle")
#define PARAM_ADDRESSCHANGE     TEXT("addresschange")
#define PARAM_REGISTER          TEXT("register")
#define PARAM_DEREGISTER        TEXT("deregister")
#define PARAM_NOTIFY            TEXT("/notify")
#define PARAM_TRANSPORT         TEXT("transport")
#define PARAM_INCLUSIVE         TEXT("inclusive")
#define PARAM_MANUAL            TEXT("manual")
#define PARAM_TCPIP             TEXT("tcpip")
#define PARAM_REFRESHSERVER     TEXT("refresh-from-server")
#define PARAM_REFRESHCLIENT     TEXT("refresh-from-client")
#define PARAM_T_REFRESHSERVER   TEXT("transport-refresh-from-server")
#define PARAM_T_REFRESHCLIENT   TEXT("transport-refresh-from-client")


//--------------------------------------------------------------------- Prototypes

static inline void Alert(const wchar_t *msg, const wchar_t *title=TEXT("Warning"));

static int getPollingTime();
static bool isServerNotified();
static void setServerNotified(bool val);

//static int polling(const wchar_t **sources);
static int schedule(bool notStartNow);
static int sync(const wchar_t **sources, const wchar_t **ids);
static int doSync(const char* mode, const wchar_t **sources, const wchar_t **ids);
int checkRefreshFromServer(const wchar_t** sources);

static bool g_debug = false;
static int retValue = 0;

void setValuesInRegistry(const wchar_t* name, const wchar_t* value);
wchar_t** getEnabledSourcesFromConfig();
void setSourceOnReg(wchar_t** sources);

//--------------------------------------------------------------- Static Functions

static inline void Alert(const wchar_t *msg, const wchar_t *title)
{
#ifdef DEBUG
  	MessageBox (NULL, msg, title, MB_SETFOREGROUND |MB_OK);
#endif
}

/*
* This function save the process id passed by setProcessId or resetProcessId on the registry
* NOT use the function directly but use (re)setProcessID instead
*/
static void writeProcessIdOnRegistry(unsigned long processId) {
    wchar_t pid[128];
    wsprintf(pid, TEXT("%lu"), processId);
    setClientConfiguration(NULL, PROPERTY_SPDM_PID, pid, NULL);
}

static void resetProcessID() {
    writeProcessIdOnRegistry(0);
}

static void setProcessID() {
    DWORD processId = GetCurrentProcessId();
    writeProcessIdOnRegistry(processId);
}


static int getPollingTime()
{

    wchar_t buf[32];

    memset(buf, 0, 32*sizeof(wchar_t));
    getClientConfigurationInternal (TEXT(""), PROPERTY_SPDM_POLLING_NOTIFICATION,
                                 buf, FALSE);
    return wcstol(buf, NULL, 10);

}

static bool isServerNotified()
{
    wchar_t buf[10];

    memset(buf, 0, 10*sizeof(wchar_t));
    getClientConfigurationInternal (TEXT(""), PROPERTY_SPDM_SERVER_NOTIFIED,
                                     buf, FALSE);
    return ( wcscmp(buf, TEXT("1")) == 0);

}

static void setServerNotified(bool val)
{

    setClientConfiguration(
            TEXT(""),
            PROPERTY_SPDM_SERVER_NOTIFIED,
            ( (val) ? TEXT("1") : TEXT("0") ),
            NULL);

}

static void getAppName(wchar_t* appName) {

    wchar_t path[256];
    getClientConfigurationInternal (NULL, PROPERTY_SPDM_PATH_INFO, path, NULL);
    wcscpy(appName, path);
    wcscat(appName, TEXT("\\"));
    wcscat(appName, SYNCAPP);

}
/*
* NOT_RETURN_TO_MAIN_FORM: is the value to avoid to send a message for the result page.
*/


static int schedule(bool notStartNow)
{
    long t = getPollingTime();

    WCHAR appName[MAX_PATH];
    getAppName(appName);
    SYSTEMTIME lpTime;
    SYSTEMTIME pollTime;

    LOG.debug("Schedule start");

    //if (t > 0 && !isServerNotified()) {
    if (t > 0) {

        if (notStartNow == false) {
            LOG.debug("Re-scheduling");
            //
            // Schedule the polling before running the sync.
            // it needs to avoid disable of polling if the user stops the sync.
            //
            GetLocalTime(&lpTime);
            pollTime = DT_AddDiff(nano100SecInMin, t, &lpTime);
            CeRunAppAtTime(appName,&pollTime);

            LOG.debug("sync");
            //retValue = sync(NULL, NULL);
            retValue = NOT_RETURN_TO_MAIN_FORM;
            LOG.debug("Re-scheduling");
            LOG.debug(_wcc(appName));
        }
        // The sync start
        else {
            GetLocalTime(&lpTime);
            pollTime = DT_AddDiff(nano100SecInMin, t, &lpTime);
            if (CeRunAppAtTime(appName,&pollTime)) {
                retValue = NOT_RETURN_TO_MAIN_FORM;
            }
        }

    }
    if (t == 0) {
        CeRunAppAtTime(appName,0);
        retValue = NOT_RETURN_TO_MAIN_FORM;
    }
    LOG.debug("Schedule end");
    return retValue;
}


static int sync(const wchar_t **sources = NULL, const wchar_t **ids = NULL)
{
    return doSync(NULL, sources, ids);
}

static int recover(const char* mode, const wchar_t **sources)
{
    return doSync(mode, sources, NULL);
}

//static int inclusive(const wchar_t **sources)
//{
//    doSync(mode, sources, NULL);
//}

/**
 * @param sources - syncronize the specified sources. Default is NULL: it means the sources
 *                to sync are the one set in the registry
 * @param ids - the ids of the mail to be downloaded with a inclusive filter
 *              usually it is NULL. Not null only with the "inclusive" command line
 */
static int doSync(const char* mode, const wchar_t **sources, const wchar_t **ids)
{
    HANDLE hMutex;//Handle to mutex...

    //HWND  wnd = NULL;

    // Create mutex here
    hMutex = CreateMutex(NULL, TRUE, TEXT("FunSyncInProgress") );

    switch(GetLastError()) {
        case ERROR_SUCCESS:
            LOG.debug("Mutex created.");
            break;
        case ERROR_ALREADY_EXISTS:
            if (g_debug)
                Alert(TEXT("Another sync in progress"), TEXT("Warning"));
            LOG.error("Another sync in progress");
            retValue = ERR_ANOTHER_SYNC;
            return ERR_ANOTHER_SYNC;
        default:
            LOG.error("Failed to create mutex");
            return -1;
    }
    /*
    wnd = HwndFunctions::getWindowHandle();

    // Moved in maincpp
    if (wnd) {
        HwndFunctions::closePreviousMsgBox();
        SendMessage(wnd, (WM_APP+4), NULL, NULL ); //-- send starting sync message to UI
    } else {
        //MessageBox (NULL, TEXT("wnd empty"), TEXT ("test"), MB_SETFOREGROUND |MB_OK);
    }
    */
    wchar_t path[DIM_PATH];
    getClientConfigurationInternal(NULL, PROPERTY_SPDM_PATH_INFO, path, NULL);

    HANDLE handleBubble = CreateThread(NULL, 0, createBubble, NULL, 0, NULL);
    if (handleBubble == 0) {
        LOG.error("CreateThread failed: <0x%08x>\n", GetLastError());
    }
    WaitForSingleObject(handleBubble, 0);

    setProcessID();
    retValue = synchronize(path, sources, ids, mode);
    resetProcessID();

    CloseHandle( hMutex );
    LOG.debug("Mutex released.");

    return retValue;
}

static int notify(const wchar_t **sources=NULL)
{
    AN_ResponseCode responseCode = notifyAddressChange(TEXT(APPLICATION_URI));

    if(responseCode == AN_AddressAccepted ){
        setServerNotified(true);
    }
    else {
        setServerNotified(false);
    }
    return NOT_RETURN_TO_MAIN_FORM;
}

/**
 * Parse the command line
 *
 * @param cmdline - the command line (syntax: command [source,source,...])
 *
 * @param command (out) - the command name
 * @param sources (out) - a NULL terminated array of source names
 */
static int parseCmdLine(const LPTSTR cmdline,
                        wchar_t **command,
                        wchar_t ***sources)
{
    if( wcsstr(cmdline, TEXT("debug ")) ) {
        *command = wstrdup(cmdline+wcslen(TEXT("debug ")));
        g_debug = true;
    }
    else {
        *command = wstrdup(cmdline);
        g_debug = false;
    }

    *sources = NULL;

    wchar_t *args = wcschr(*command, ' ');
    if(!args) {
        // in this case comand == cmdline and sources is null
        return 0;
    }
    // terminate command and point to the start of arguments
    args[0] = 0; args++;
    if (!args[0]) {
        // empty args after a space, like before
        return 0;
    }
    int argc;
    wchar_t *arg = args;
    // Count arguments
    for(argc = 1; (arg=wcschr(arg+1, ',')) != 0; argc++);

    // Get arg list
    wchar_t **srclist = new wchar_t *[argc+1];
    arg=args;
    int i;

    for(i=0; i<argc; i++) {
        if(!arg || !arg[0])
            return -1;
        srclist[i]=arg;

        arg=wcschr(arg, ',');
        if(arg) {
            arg[0]=0; arg++;
        }
    }
    srclist[i]=0;
    *sources=srclist;

    return 0;
}

static void exitHandler() {
    if (retValue != ERR_ANOTHER_SYNC) {
        removeNotif();
        HwndFunctions::closePreviousMsgBox();
        HWND hwnd = HwndFunctions::getWindowHandle();
        //HWND hwnd2 = HwndFunctions::getAccountWindowHandle();
        //::SendMessage(hwnd2, WM_COMMAND,   (WPARAM) 6, NULL);

        if (hwnd && retValue != NOT_RETURN_TO_MAIN_FORM) {
            SendMessage(hwnd, (WM_APP+3), NULL, (LPARAM)retValue ); // send msg startsync ended
        } else if (retValue == -40) {
            MessageBox (NULL, getLocalizationUtils()->getLocalizationString(IDS_ERR_OUT_OF_MEMORY), getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT), MB_SETFOREGROUND | MB_ICONWARNING |MB_OK);
            //showMessage(IDS_ERR_OUT_OF_MEMORY);
        } else if (retValue == -50) {
            MessageBox (NULL, getLocalizationUtils()->getLocalizationString(IDS_ERR_LOW_MEM), getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT), MB_SETFOREGROUND | MB_ICONWARNING |MB_OK);
            //showMessage(IDS_ERR_LOW_MEM);
        }
    }
    if (retValue == -6) { // sync stopped by the user
        // reset the pid property
        resetProcessID();
    }
}

//------------------------------------------------------------ Public functions
void quit(int value) {
    retValue = value;
    exit(retValue);
}




//------------------------------------------------------------------------ MAIN
int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPTSTR    lpCmdLine,
                   int       nCmdShow) {
         
    _set_new_mode(1);
    _set_new_handler(operatorNewHandler);
    // Set the exit handler to remove the icon
    atexit(exitHandler);
    try {
        //MessageBox (NULL, TEXT("stsync"), TEXT("title"), MB_SETFOREGROUND |MB_OK);
        wchar_t *command, **sources;

        HRESULT         hr              = NOERROR;
        HANDLE          hevtMsgAvailable= NULL;
        HPUSHROUTER     hPushRouter     = NULL;
        PUSHMSG         PushMsg         = {0};

        PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE);
        //SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_BELOW_NORMAL);
        
        if(g_debug){
            Alert(lpCmdLine);
        }

        if (parseCmdLine(lpCmdLine, &command, &sources)) {
            Alert(TEXT("Syntax error in command line"), TEXT("StartSync"));
            return 1;
        }
        
        if(!(wcscmp(command,PARAM_AVAILABLE) == 0 ||
            wcscmp(command, PARAM_REMOVENOTIF) == 0 ||
            wcscmp(command, PARAM_SCHEDULE) == 0 ||
            wcscmp(command, PARAM_CRADLE) == 0 ||

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲乱码一区二区三区在线观看| 国产欧美视频一区二区三区| 色噜噜狠狠色综合中国| 91在线观看成人| 欧美性高清videossexo| 91麻豆精品国产91久久久 | 精品久久久久久最新网址| 精品国产乱码久久| 国产精品剧情在线亚洲| 一区二区免费看| 蜜臀99久久精品久久久久久软件| 国产在线麻豆精品观看| 色悠悠久久综合| 久久久一区二区三区捆绑**| 一区二区三区不卡视频在线观看| 国产综合色在线| 欧美中文字幕亚洲一区二区va在线| 26uuu国产一区二区三区| 日韩一区在线播放| 国产精品99久| 日韩一区二区三区四区五区六区| 亚洲女人小视频在线观看| 国精品**一区二区三区在线蜜桃| 91精品福利视频| 国产精品女上位| 国产99久久久国产精品免费看 | 亚洲男人的天堂av| www.日韩在线| 国产精品久99| 91一区二区三区在线播放| 中文字幕色av一区二区三区| 国产一区二区三区黄视频| 精品噜噜噜噜久久久久久久久试看| 亚洲国产一区视频| 欧美性大战久久| 日日摸夜夜添夜夜添国产精品| 欧美亚洲动漫制服丝袜| 午夜电影一区二区| 日韩欧美一区在线观看| 蜜臀av性久久久久蜜臀aⅴ| 欧美xxxxxxxxx| 成人一二三区视频| 国产精品嫩草99a| 欧美性视频一区二区三区| 午夜久久电影网| 久久综合网色—综合色88| 成人v精品蜜桃久久一区| 亚洲老妇xxxxxx| 日韩免费观看高清完整版 | 欧美韩日一区二区三区四区| 99久久精品国产观看| 天天操天天色综合| 欧美精品一区二区三区高清aⅴ| 成人涩涩免费视频| 香蕉成人啪国产精品视频综合网| 精品久久国产97色综合| 91在线播放网址| 激情五月婷婷综合| 亚洲国产精品久久人人爱| 久久久久久一级片| 日韩午夜小视频| 秋霞电影网一区二区| 在线精品视频免费观看| 精品伊人久久久久7777人| 日韩欧美激情四射| 在线观看免费视频综合| 成人自拍视频在线观看| 午夜精品一区二区三区电影天堂| 国产精品色噜噜| 91精品午夜视频| 色综合天天综合给合国产| 国产精品一品二品| 久久99在线观看| 午夜精品影院在线观看| 伊人色综合久久天天| 久久免费视频一区| 欧美年轻男男videosbes| 色天天综合色天天久久| 99精品欧美一区| caoporn国产精品| 成人妖精视频yjsp地址| 风间由美性色一区二区三区| 精品在线免费观看| 国内成+人亚洲+欧美+综合在线| 日韩av电影免费观看高清完整版| 亚洲第一综合色| 日韩**一区毛片| 国产美女精品人人做人人爽| 精油按摩中文字幕久久| 久久国产成人午夜av影院| 久久精品国产99久久6| 精品一区二区在线视频| 日韩国产欧美在线视频| 天天色综合天天| 国产一区在线视频| 97精品视频在线观看自产线路二| 色噜噜狠狠成人网p站| 欧美日韩在线精品一区二区三区激情 | 亚洲一区在线电影| 五月婷婷综合在线| 精品一区二区三区免费视频| 丁香婷婷综合激情五月色| 色素色在线综合| 欧美精品一区男女天堂| 亚洲男女毛片无遮挡| 日本91福利区| 91成人在线精品| 精品国产一二三| 亚洲国产日韩综合久久精品| 国产伦理精品不卡| 制服丝袜亚洲色图| 亚洲欧美偷拍三级| 极品销魂美女一区二区三区| 欧美性大战久久| 一区二区在线观看视频| 国产成人午夜精品5599 | 美女视频一区在线观看| 色婷婷久久综合| 一区精品在线播放| 免费观看一级特黄欧美大片| 成人少妇影院yyyy| 精品国产污污免费网站入口| 国产精品第五页| 国产精品123区| 91精品黄色片免费大全| 成人欧美一区二区三区| 国产麻豆欧美日韩一区| 日韩亚洲国产中文字幕欧美| 一区二区三区电影在线播| 国产精品伊人色| 精品久久久久久久久久久久久久久 | av影院午夜一区| 欧美精品一二三| 亚洲四区在线观看| 91原创在线视频| 亚洲精品一二三| 一本大道av伊人久久综合| 亚洲精品大片www| 亚洲电影一区二区三区| 欧美日韩一二区| 亚洲电影一级黄| 99国内精品久久| 一区二区三区在线免费视频| 欧美羞羞免费网站| 一二三区精品福利视频| 777xxx欧美| 成人av在线资源网| ww亚洲ww在线观看国产| 成人激情文学综合网| 一区二区视频在线看| 欧美日韩1区2区| 国产成人午夜精品影院观看视频| 国产精品区一区二区三区| 91精品福利视频| 国产精品一区免费视频| 一片黄亚洲嫩模| 日本一区二区久久| 欧美日本一道本| 波多野结衣一区二区三区| 亚洲区小说区图片区qvod| 日韩一区二区三区视频在线观看| 粉嫩13p一区二区三区| 石原莉奈在线亚洲二区| 国产女人aaa级久久久级| 欧美一级一区二区| 99综合电影在线视频| 久久er精品视频| 日韩专区一卡二卡| 亚洲在线观看免费视频| 亚洲国产高清在线观看视频| 欧美日韩在线三级| 欧美主播一区二区三区美女| 成人午夜精品在线| 国产成人精品亚洲午夜麻豆| 精品系列免费在线观看| 蜜桃久久久久久| 免费在线欧美视频| 国产视频在线观看一区二区三区| 欧美一区二区视频在线观看| 宅男噜噜噜66一区二区66| 欧美日韩不卡一区| 日韩一区二区三区视频在线观看| 欧美日韩精品系列| 欧美美女喷水视频| 欧美亚洲自拍偷拍| 欧美日韩在线精品一区二区三区激情| 国产成人精品亚洲777人妖| 精品一区二区三区蜜桃| 美女视频一区二区三区| 久久精品国产在热久久| 国产一区二区三区美女| 不卡的av中国片| 欧美三级视频在线| 精品不卡在线视频| 中文字幕乱码日本亚洲一区二区| 国产精品毛片a∨一区二区三区| 欧美xxxxxxxxx| 中文字幕一区二区三区四区| 亚洲一区二区不卡免费| 一区二区三区中文字幕电影|