void TrackingSyncSource::checkStatus(SyncSourceReport &changes) { // use the most reliable (and most expensive) method by default ChangeMode mode = CHANGES_FULL; // assume that we do a regular sync, with reusing stored information // if possible string oldRevision = m_metaNode->readProperty("databaseRevision"); if (!oldRevision.empty()) { string newRevision = databaseRevision(); SE_LOG_DEBUG(this, NULL, "old database revision '%s', new revision '%s'", oldRevision.c_str(), newRevision.c_str()); if (newRevision == oldRevision) { SE_LOG_DEBUG(this, NULL, "revisions match, no item changes"); mode = CHANGES_NONE; } } if (mode == CHANGES_FULL) { SE_LOG_DEBUG(this, NULL, "using full item scan to detect changes"); } detectChanges(*m_trackingNode, mode); // copy our item counts into the report changes.setItemStat(ITEM_LOCAL, ITEM_ADDED, ITEM_TOTAL, getNewItems().size()); changes.setItemStat(ITEM_LOCAL, ITEM_UPDATED, ITEM_TOTAL, getUpdatedItems().size()); changes.setItemStat(ITEM_LOCAL, ITEM_REMOVED, ITEM_TOTAL, getDeletedItems().size()); changes.setItemStat(ITEM_LOCAL, ITEM_ANY, ITEM_TOTAL, getAllItems().size()); }
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; }
/* * 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; }