Exemplo n.º 1
0
    /** Test the SyncSourceEvent */
    void testSyncSourceEvent() {
        const char *uri="testUri", *name="test";
        fireSyncSourceEvent(uri, name, SYNC_TWO_WAY, 0, SYNC_SOURCE_BEGIN);
        fireSyncSourceEvent(uri, name, SYNC_TWO_WAY, 0, SYNC_SOURCE_END);
        fireSyncSourceEvent(uri, name, SYNC_TWO_WAY, 0, SYNC_SOURCE_SYNCMODE_REQUESTED);
        fireSyncSourceEvent(uri, name, SYNC_TWO_WAY, 0, SYNC_SOURCE_TOTAL_CLIENT_ITEMS);
        fireSyncSourceEvent(uri, name, SYNC_TWO_WAY, 0, SYNC_SOURCE_TOTAL_SERVER_ITEMS);

        TSyncSourceListener* s = 
            static_cast<TSyncSourceListener*>(
                ManageListener::getInstance().getSyncSourceListener("T1"));
        s->checkp();

        s = static_cast<TSyncSourceListener*>(
            ManageListener::getInstance().getSyncSourceListener("T2"));
        s->checkp();
    }
Exemplo n.º 2
0
Sync* SyncMLProcessor::processSyncResponse(SyncSource& source, SyncML* syncml) {

    int iterator = 0, ret = 0;

    AbstractCommand* a  = NULL;
    Sync* sync          = NULL;

    ret = getStatusCode(syncml->getSyncBody(), &source, SYNC_HDR);
    if ((ret < 200) || (ret > 299)) {
        goto finally;
    }

    while((a = getCommand(syncml->getSyncBody(), SYNC, iterator)) != NULL){
        sync = (Sync*)a;
        const char *locuri = ((Target*)(sync->getTarget()))->getLocURI();
        if (strcmp(locuri, _wcc(source.getName())) == 0) {

            //
            // To handle the NumberOfChanges. The default is -1 that means the server doesn't send
            // any tag <NumberOfChanges>. Whit value >= 0 the value is correct
            //

            long noc = sync->getNumberOfChanges();
            fireSyncSourceEvent(source.getConfig().getURI(), source.getConfig().getName(), source.getSyncMode(), noc, SYNC_SOURCE_TOTAL_SERVER_ITEMS);

            break;
        }
        sync = NULL;
        iterator++;
    }

finally:

    return sync;

}