WindowsSyncSource* createAppointmentWindowsSyncSource() {

    OutlookConfig* config = getConfig();
    config->getServerConfig().setNoFieldLevelReplace("event");

    WIN_ASSERT_NOT_NULL(config, TEXT("The config is null. Please verify the an Outlook client is already installed"));
    SyncSourceConfig* sc = config->getSyncSourceConfig(APPOINTMENT_);
    WindowsSyncSource* ss = new WindowsSyncSource(APPOINTMENT, sc);
    int ret = ss->beginSync();   
    WIN_ASSERT_ZERO(ret, TEXT("beginSync is not 0"));

    SyncSourceReport* ssReport = new SyncSourceReport();
    ssReport->setSourceName(sc->getName());
    ssReport->setState(SOURCE_ACTIVE);
    ss->setReport(ssReport);

    return ss;

}
Exemple #2
0
/*
* Used to start the sync process. The argument is an array of SyncSources
* that have to be synched with the sync process
*/
int SyncClient::sync(AbstractSyncConfig& config, SyncSource** sources) {

    resetError();
    int ret = 0;

    if (!config.getAbstractSyncSourceConfigsCount()) {
        //sprintf(lastErrorMsg, "Error in sync() - configuration not set correctly.");
        ret = 1;
        setError(ret, "Error in sync() - configuration not set correctly.");
        
        LOG.error("%s", getLastErrorMsg());
        return ret;
    }

    //
    // Synchronization report.
    //
    syncReport.setSyncSourceReports(config);
    // Set source report on each SyncSource (assign pointer)
    int i=0;
    while (sources[i]) {
        char* name = toMultibyte(sources[i]->getName());
        SyncSourceReport *ssr = syncReport.getSyncSourceReport(name);
        ssr->setState(SOURCE_ACTIVE);
        sources[i]->setReport(ssr);

        delete[] name;
        i++;
    }

    SyncManager syncManager(config, syncReport);

    if ((ret = syncManager.prepareSync(sources))) {
        LOG.error("Error in preparing sync: %s", getLastErrorMsg());
        goto finally;
    }

    ret = continueAfterPrepareSync();
    if (ret) {
        LOG.error("SyncClient: continueAfterPrepareSync returns error code: %d.", ret);
        goto finally;
    }

    if ((ret = syncManager.sync())) {
        LOG.error("Error in syncing: %s", getLastErrorMsg());
        goto finally;
    }

    ret = continueAfterSync();
    if (ret) {
        LOG.error("SyncClient: continueAfterSync returns error code: %d.", ret);
        goto finally;
    }

    if ((ret = syncManager.endSync())) {
        LOG.error("Error in ending sync: %s", getLastErrorMsg());
        goto finally;
    }

finally:

    // Update SyncReport with last error from sync
    syncReport.setLastErrorCode(getLastErrorCode());
    syncReport.setLastErrorMsg(getLastErrorMsg());

    return ret;
}