diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/sysync/binfileimplclient.cpp | 36 | ||||
-rwxr-xr-x | src/sysync/binfileimplds.cpp | 256 | ||||
-rw-r--r-- | src/sysync/itemfield.cpp | 44 | ||||
-rwxr-xr-x | src/sysync/itemfield.h | 6 | ||||
-rw-r--r-- | src/sysync/localengineds.cpp | 188 | ||||
-rwxr-xr-x | src/sysync/localengineds.h | 14 | ||||
-rw-r--r-- | src/sysync/stdlogicds.cpp | 56 | ||||
-rwxr-xr-x | src/sysync/stdlogicds.h | 38 |
8 files changed, 319 insertions, 319 deletions
diff --git a/src/sysync/binfileimplclient.cpp b/src/sysync/binfileimplclient.cpp index 1a09877..8b6804d 100755 --- a/src/sysync/binfileimplclient.cpp +++ b/src/sysync/binfileimplclient.cpp @@ -359,7 +359,7 @@ TSyError TBinfileTargetsKey::OpenSubkey( // - find related datastore config (by dbtypeid) TBinfileDSConfig *dsCfgP = static_cast<TBinfileDSConfig *>( fBinfileClientConfigP->getLocalDS(NULL,targetP->localDBTypeID) - ); + ); if (dsCfgP==NULL) { // this target entry is not configured in the config -> skip it while iterating, // or return "DB error" if explicitly addressed @@ -910,7 +910,7 @@ static TSyError readMayLooseOldConfig( appPointer aBuffer, memSize aBufSize, memSize &aValSize ) { - return TStructFieldsKey::returnInt(static_cast<TBinfileProfilesKey *>(aStructFieldsKeyP)->fMayLooseOldCfg, 1, aBuffer, aBufSize, aValSize); + return TStructFieldsKey::returnInt(static_cast<TBinfileProfilesKey *>(aStructFieldsKeyP)->fMayLooseOldCfg, 1, aBuffer, aBufSize, aValSize); } // readMayLooseOldConfig @@ -922,7 +922,7 @@ static TSyError writeMayLooseOldConfig( { // set flag static_cast<TBinfileProfilesKey *>(aStructFieldsKeyP)->fMayLooseOldCfg = - *((uInt8 *)aBuffer); + *((uInt8 *)aBuffer); return LOCERR_OK; } // writeMayLooseOldConfig @@ -1250,8 +1250,8 @@ TBinfileClientConfig::~TBinfileClientConfig() // init defaults void TBinfileClientConfig::clear(void) { - // Only active in clients by default - fBinfilesActive = IS_CLIENT; + // Only active in clients by default + fBinfilesActive = IS_CLIENT; #ifndef HARDCODED_CONFIG // init defaults fSeparateChangelogs = true; // for engine libraries with full config, use separated changelogs by default (auto-migration w/o side effects is built-in) @@ -1435,9 +1435,9 @@ void TBinfileClientConfig::getBinFilesPath(string &aPath) // open settings databases localstatus TBinfileClientConfig::openSettingsDatabases(bool aDoLoose) { - if (!fBinfilesActive) { - // databases can be opened only with active binfiles layer - return LOCERR_WRONGUSAGE; + if (!fBinfilesActive) { + // databases can be opened only with active binfiles layer + return LOCERR_WRONGUSAGE; } else { // safe for calling more than once @@ -1480,7 +1480,7 @@ localstatus TBinfileClientConfig::openSettingsDatabases(bool aDoLoose) return LOCERR_CFGPARSE; // this is kind of a config parsing error } } - return err; + return err; } } // TBinfileClientConfig::openSettingsDatabases @@ -1526,7 +1526,7 @@ localstatus TBinfileClientConfig::loadVarConfig(bool aDoLoose) // save app state (such as settings in datastore configs etc.) void TBinfileClientConfig::saveAppState(void) { - if (fBinfilesActive) { + if (fBinfilesActive) { // close and re-open the settings binfiles to make sure their // contents is permanently saved closeSettingsDatabases(); @@ -2319,7 +2319,7 @@ void TBinfileClientConfig::cleanChangeLogForDBname(cAppCharP aDBName, sInt32 aPr string basefilename = relatedDBNameBase(aDBName, aProfileID); string filename; TBinFile binfile; - // delete changelog + // delete changelog filename = basefilename + CHANGELOG_DB_SUFFIX; binfile.setFileInfo(filename.c_str(),CHANGELOG_DB_VERSION,CHANGELOG_DB_ID,0); binfile.closeAndDelete(); @@ -2337,7 +2337,7 @@ void TBinfileClientConfig::cleanChangeLogForDBname(cAppCharP aDBName, sInt32 aPr void TBinfileClientConfig::separateDBFile(cAppCharP aDBName, cAppCharP aDBSuffix, sInt32 aProfileID) { - TBinFile sourceFile; + TBinFile sourceFile; TBinFile targetFile; string sourceName = relatedDBNameBase(aDBName, -1) + aDBSuffix; // without profile ID in name string targetName = relatedDBNameBase(aDBName, aProfileID) + aDBSuffix; // with profile ID in name @@ -2350,7 +2350,7 @@ void TBinfileClientConfig::separateDBFile(cAppCharP aDBName, cAppCharP aDBSuffix // separate changelogs and other related files into separate files for each profile void TBinfileClientConfig::separateChangeLogsAndRelated(cAppCharP aDBName) { - // iterate over all profiles + // iterate over all profiles TBinfileDBSyncProfile profile; sInt32 idx = 0; // set up original basename @@ -2464,7 +2464,7 @@ void TBinfileImplClient::InternalResetSession(void) // Virtual version void TBinfileImplClient::ResetSession(void) { - if (fConfigP->fBinfilesActive) { + if (fConfigP->fBinfilesActive) { // do my own stuff InternalResetSession(); } @@ -2585,7 +2585,7 @@ localstatus TBinfileImplClient::checkRemoteSpecifics(SmlDevInfDevInfPtr_t aDevIn // generates custom PUT in case IPP/DMU is enabled to request settings void TBinfileImplClient::issueCustomGetPut(bool aGotDevInf, bool aSentDevInf) { - if (fConfigP->fBinfilesActive) { + if (fConfigP->fBinfilesActive) { // get autosync PUT req string string req; fConfigP->autosync_get_putrequest(req); @@ -2610,7 +2610,7 @@ void TBinfileImplClient::issueCustomGetPut(bool aGotDevInf, bool aSentDevInf) // handler of custom IPP/DMU put and result commands void TBinfileImplClient::processPutResultItem(bool aIsPut, const char *aLocUri, TSmlCommand *aPutResultsCommandP, SmlItemPtr_t aPutResultsItemP, TStatusCommand &aStatusCommand) { - if (fConfigP->fBinfilesActive) { + if (fConfigP->fBinfilesActive) { #ifdef IPP_SUPPORT // check for DMU specials if (strucmp(relativeURI(aLocUri),relativeURI(IPP_PARAMS_LOCURI_CFG))==0) { @@ -2694,8 +2694,8 @@ localstatus TBinfileImplClient::SelectProfile(uInt32 aProfileSelector, bool aAut uInt32 recidx,maxidx; // detect special tunnel session's selection bool tunnel = aProfileSelector==TUNNEL_PROFILE_ID; - // select profile if active - if (fConfigP->fBinfilesActive) { + // select profile if active + if (fConfigP->fBinfilesActive) { if (tunnel) { aProfileSelector=DEFAULT_PROFILE_ID; } diff --git a/src/sysync/binfileimplds.cpp b/src/sysync/binfileimplds.cpp index b50f3fa..d110d63 100755 --- a/src/sysync/binfileimplds.cpp +++ b/src/sysync/binfileimplds.cpp @@ -21,7 +21,7 @@ #include "binfileimplds.h" #if defined(BINFILE_ALWAYS_ACTIVE) && defined(SYSYNC_SERVER) - #error "BINFILE_ALWAYS_ACTIVE is not compatible with server-enabled builds" + #error "BINFILE_ALWAYS_ACTIVE is not compatible with server-enabled builds" #endif @@ -37,37 +37,37 @@ namespace sysync { class TBFDSfuncs { public: - static TItemField *fieldFromStructField(cAppCharP aFieldName, const TStructFieldInfo *aStructFieldInfos, sInt32 aNumFields, uInt8P aStructAddr, TScriptContext *aFuncContextP) + static TItemField *fieldFromStructField(cAppCharP aFieldName, const TStructFieldInfo *aStructFieldInfos, sInt32 aNumFields, uInt8P aStructAddr, TScriptContext *aFuncContextP) { - TItemField *fldP = NULL; - // search for name + TItemField *fldP = NULL; + // search for name for (sInt32 i=0; i<aNumFields; i++) { - const TStructFieldInfo *info = &aStructFieldInfos[i]; - if (strucmp(info->valName, aFieldName)==0 && info->valSiz>0) { - // found field + const TStructFieldInfo *info = &aStructFieldInfos[i]; + if (strucmp(info->valName, aFieldName)==0 && info->valSiz>0) { + // found field if (info->valType==VALTYPE_TEXT) { - // text - fldP = newItemField(fty_string, aFuncContextP->getSessionZones()); + // text + fldP = newItemField(fty_string, aFuncContextP->getSessionZones()); fldP->setAsString((cAppCharP)(aStructAddr+info->fieldOffs)); return fldP; } else if (info->valType==VALTYPE_TIME64) { - // timestamp - fldP = newItemField(fty_timestamp, aFuncContextP->getSessionZones()); + // timestamp + fldP = newItemField(fty_timestamp, aFuncContextP->getSessionZones()); static_cast<TTimestampField *>(fldP)->setTimestampAndContext( - *((lineartime_t *)(aStructAddr+info->fieldOffs)), + *((lineartime_t *)(aStructAddr+info->fieldOffs)), TCTX_UTC // internal timestamps are UTC ); return fldP; } else { - // all other types are treated as integers + // all other types are treated as integers fieldinteger_t fint = 0; switch(info->valSiz) { - case 1 : fint = *((uInt8 *)(aStructAddr+info->fieldOffs)); break; - case 2 : fint = *((uInt16 *)(aStructAddr+info->fieldOffs)); break; - case 4 : fint = *((uInt32 *)(aStructAddr+info->fieldOffs)); break; - case 8 : fint = *((uInt64 *)(aStructAddr+info->fieldOffs)); break; + case 1 : fint = *((uInt8 *)(aStructAddr+info->fieldOffs)); break; + case 2 : fint = *((uInt16 *)(aStructAddr+info->fieldOffs)); break; + case 4 : fint = *((uInt32 *)(aStructAddr+info->fieldOffs)); break; + case 8 : fint = *((uInt64 *)(aStructAddr+info->fieldOffs)); break; } fldP = newItemField(fty_integer, aFuncContextP->getSessionZones()); fldP->setAsInteger(fint); @@ -92,7 +92,7 @@ public: aFuncContextP->getLocalVar(0)->getAsString(varname); // get value aTermP = fieldFromStructField( - varname.c_str(), + varname.c_str(), ProfileFieldInfos, numProfileFieldInfos, (uInt8P)&(static_cast<TBinfileImplClient *>(dsP->getSession())->fProfile), aFuncContextP @@ -110,7 +110,7 @@ public: aFuncContextP->getLocalVar(0)->getAsString(varname); // get value aTermP = fieldFromStructField( - varname.c_str(), + varname.c_str(), TargetFieldInfos, numTargetFieldInfos, (uInt8P)&(dsP->fTarget), aFuncContextP @@ -170,10 +170,10 @@ TBinfileDSConfig::~TBinfileDSConfig() // init defaults void TBinfileDSConfig::clear(void) { - // Only active in clients by default - fBinfileDSActive = IS_CLIENT; + // Only active in clients by default + fBinfileDSActive = IS_CLIENT; // change detection by CRC is enabled by default only for builds that CAN'T have DB-side detection - #ifdef CHANGEDETECTION_AVAILABLE + #ifdef CHANGEDETECTION_AVAILABLE fCRCChangeDetection = false; // normally, DB can report changes. CRC checking can be enabled as an option fCRCPseudoChangeDetection = false; // normally, DB reports changes correctly. Verifying changes can be enabled as an option #endif @@ -205,7 +205,7 @@ bool TBinfileDSConfig::localStartElement(const char *aElementName, const char ** expectBool(fCmpRefTimeStampAtEnd); else if (strucmp(aElementName,"binfiledsactive")==0) expectBool(fBinfileDSActive); - #ifdef CHANGEDETECTION_AVAILABLE + #ifdef CHANGEDETECTION_AVAILABLE else if (strucmp(aElementName,"crcchangedetection")==0) expectBool(fCRCChangeDetection); else if (strucmp(aElementName,"pseudochangedetection")==0) @@ -228,7 +228,7 @@ void TBinfileDSConfig::localResolve(bool aLastPass) #ifdef CHANGEDETECTION_AVAILABLE // - pseudochange detection would interfere with regular CRC based change detection and is also completely useless then if (fCRCChangeDetection) fCRCPseudoChangeDetection = false; // just switch it off, makes no sense - #endif + #endif } // resolve inherited inherited::localResolve(aLastPass); @@ -415,7 +415,7 @@ bool TBinfileImplDS::dsSetClientSyncParams( bool aFilterInclusive ) { - if (binfileDSActive()) { + if (binfileDSActive()) { #ifdef AUTOSYNC_SUPPORT string s; bool cgi=false; @@ -461,11 +461,11 @@ localstatus TBinfileImplDS::changeLogPostflight(uInt32 aOldestSyncModCount) fChangeLog.deleteRecord(logindex); } else { - // no delete, finalize localid (possible only with string localIDs) + // no delete, finalize localid (possible only with string localIDs) #ifndef NUMERIC_LOCALIDS localid_out_t locID = logentry.dbrecordid; if (dsFinalizeLocalID(locID)) { - // update log entry + // update log entry ASSIGN_LOCALID_TO_FLD(logentry.dbrecordid,LOCALID_OUT_TO_IN(locID)); fChangeLog.updateRecord(logindex, &logentry); } @@ -509,12 +509,12 @@ static uInt32 changelogUpdateFunc(uInt32 aOldVersion, uInt32 aNewVersion, void * if (aNewVersion!=CHANGELOG_DB_VERSION) return 0; // cannot update to other version than current // create default values for profile if (aOldRecordData && aNewRecordData) { - // update records + // update records TChangeLogEntry *chglogEntryP = (TChangeLogEntry *)aNewRecordData; // check for special case that old record is V2 or V3 and was compiled without CHANGEDETECTION_AVAILABLE uInt16 crc = 0; if ((aOldVersion==2 || aOldVersion==3) && aOldSize!=offsetof(TChangeLogEntry,modcount_created)) { - // this means that the records were compiled without CHANGEDETECTION_AVAILABLE and had a + // this means that the records were compiled without CHANGEDETECTION_AVAILABLE and had a // dataCRC field between modcount and flags //#if defined(WINCE) || #if defined(__PALM_OS__) @@ -523,7 +523,7 @@ static uInt32 changelogUpdateFunc(uInt32 aOldVersion, uInt32 aNewVersion, void * // - offset of the CRC field we already have int o = offsetof(TChangeLogEntry,flags); // - copy up to the CRC which is already there - memcpy(aNewRecordData,aOldRecordData,o); + memcpy(aNewRecordData,aOldRecordData,o); // - get the CRC which is already there to init the new V5 DB field below crc = *((uInt16 *)((uInt8 *)aOldRecordData+o)); // - also copy the flags @@ -540,22 +540,22 @@ static uInt32 changelogUpdateFunc(uInt32 aOldVersion, uInt32 aNewVersion, void * chglogEntryP->modcount_created = 0; // assume created before changelogging history started } if (aOldVersion<5) { - // init new V5 dataCRC; if we are updating from V2 or V3 (which is handled above) we'll assign the previous CRC here, 0 otherwise + // init new V5 dataCRC; if we are updating from V2 or V3 (which is handled above) we'll assign the previous CRC here, 0 otherwise chglogEntryP->dataCRC = crc; } } else if (aNewRecordData) { - // update extra header + // update extra header TChangeLogHeader *extraHeaderP = (TChangeLogHeader *)aNewRecordData; if (aOldVersion<3) { - // header has got new fields between v2 and v3 + // header has got new fields between v2 and v3 // Note: these will be updated with data from target fields after actually opening the changelog // Just init them now extraHeaderP->lastChangeCheckIdentifier[0] = 0; extraHeaderP->lastChangeCheck = noLinearTime; } // updated header ok - return sizeof(TChangeLogHeader); + return sizeof(TChangeLogHeader); } // updated ok (or updateable ok if no data pointers provided) // - return size of new record @@ -575,41 +575,41 @@ bool TBinfileImplDS::openChangeLog(void) changelogname += CHANGELOG_DB_SUFFIX; fChangeLog.setFileInfo(changelogname.c_str(),CHANGELOG_DB_VERSION,CHANGELOG_DB_ID,sizeof(TChangeLogEntry)); if (fChangeLog.open(sizeof(TChangeLogHeader),&fChgLogHeader,changelogUpdateFunc)!=BFE_OK) { - // can't open changelog - check if we might need need migration from united changelogs to separated + // can't open changelog - check if we might need need migration from united changelogs to separated if (bfcfgP->fSeparateChangelogs) { - // check if we have the old united changelog and migrate everything if so + // check if we have the old united changelog and migrate everything if so string unitedchangelogname = bfcfgP->relatedDBNameBase(getName(), -1); // united name unitedchangelogname += CHANGELOG_DB_SUFFIX; fChangeLog.setFileInfo(unitedchangelogname.c_str(),CHANGELOG_DB_VERSION,CHANGELOG_DB_ID,sizeof(TChangeLogEntry)); - if (fChangeLog.open(sizeof(TChangeLogHeader),&fChgLogHeader,changelogUpdateFunc)==BFE_OK) { - // the old unified changelog is there - we need to do a full migration now + if (fChangeLog.open(sizeof(TChangeLogHeader),&fChgLogHeader,changelogUpdateFunc)==BFE_OK) { + // the old unified changelog is there - we need to do a full migration now // - close it fChangeLog.close(); // - perform migration for this DB - PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI,("openChangeLog: auto-migrating from common to profile-separated changelog for this datastore")); + PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI,("openChangeLog: auto-migrating from common to profile-separated changelog for this datastore")); bfcfgP->separateChangeLogsAndRelated(getName()); // - recursively call myself, now the profile specific log should be there return openChangeLog(); } // we're not migrating (we could not open the changelog because this is a new profile!) // - restore the per-profile name for creation of new log below - fChangeLog.setFileInfo(changelogname.c_str(),CHANGELOG_DB_VERSION,CHANGELOG_DB_ID,sizeof(TChangeLogEntry)); + fChangeLog.setFileInfo(changelogname.c_str(),CHANGELOG_DB_VERSION,CHANGELOG_DB_ID,sizeof(TChangeLogEntry)); } // create new change log or overwrite incompatible one // - init changelog header fields fChgLogHeader.modcount=0; //set all bytes to zero to avoid memory warnings memset(fChgLogHeader.lastChangeCheckIdentifier, 0, changeIndentifierMaxLen); - fChgLogHeader.lastChangeCheck = noLinearTime; + fChgLogHeader.lastChangeCheck = noLinearTime; // - create new changelog fChangeLog.create(sizeof(TChangeLogEntry),sizeof(TChangeLogHeader),&fChgLogHeader,true); PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI,("openChangeLog: changelog did not exist (or bad version) -> created new")); return false; // changelog is new, so we need a slow sync } else { - // check if opening was an upgrade from version 2 + // check if opening was an upgrade from version 2 if (fChangeLog.getFoundVersion()<3) { - // version 3 has introduced saving the last-check date/identifiers in the changelog header, + // version 3 has introduced saving the last-check date/identifiers in the changelog header, // before that the identifiers used where (wrongly) those of the target. So copy // the target info to the new header now. This gives perfect results only for single // profile use, but existing products before update to v3 were single profile so we can @@ -617,14 +617,14 @@ bool TBinfileImplDS::openChangeLog(void) #if TARGETS_DB_VERSION>5 // - dummyIdentifier1 is the former lastSyncIdentifier and contains the token from the // last change check towards the DB (in case sync identifiers are available at all) - AssignCString(fChgLogHeader.lastChangeCheckIdentifier,fTarget.dummyIdentifier1,changeIndentifierMaxLen); + AssignCString(fChgLogHeader.lastChangeCheckIdentifier,fTarget.dummyIdentifier1,changeIndentifierMaxLen); #endif // - lastChangeCheck is the former lastTwoWaySync and contains the timestamp of the last change check towards the DB - fChgLogHeader.lastChangeCheck = fTarget.lastChangeCheck; + fChgLogHeader.lastChangeCheck = fTarget.lastChangeCheck; // - make sure it gets written back fChangeLog.setExtraHeaderDirty(); fChangeLog.flushHeader(); - PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI,("openChangeLog: upgraded changelog from V2 to V4 (new header, new modcount_created)")); + PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI,("openChangeLog: upgraded changelog from V2 to V4 (new header, new modcount_created)")); } } return true; // changelog already existed, so we assume it's up-to-date @@ -757,7 +757,7 @@ localstatus TBinfileImplDS::changeLogPreflight(bool &aValidChangelog) // Now update the changelog using CRC checks // loop through entire database if (CRC_CHANGE_DETECTION) { - // we do change detection via CRC comparison + // we do change detection via CRC comparison #ifdef RECORDHASH_FROM_DBAPI // - DB can deliver CRC directly foundone = getFirstItemCRC(itemLocalID,dataCRC); @@ -767,7 +767,7 @@ localstatus TBinfileImplDS::changeLogPreflight(bool &aValidChangelog) #endif } else { - #ifdef CHANGEDETECTION_AVAILABLE + #ifdef CHANGEDETECTION_AVAILABLE // - the DB layer can report changes directly foundone = getFirstItemInfo(itemLocalID,itemIsModified); #else @@ -785,10 +785,10 @@ localstatus TBinfileImplDS::changeLogPreflight(bool &aValidChangelog) #ifdef RECORDHASH_FROM_DBAPI // with or without CRC, we have got the ID into itemLocalID already localid=LOCALID_OUT_TO_IN(itemLocalID); - #else - if (CRC_CHANGE_DETECTION) { - // with CRC, we have got the entire item, so we need to get the ID out of that - STR_TO_LOCALID(itemP->getLocalID(),localid); + #else + if (CRC_CHANGE_DETECTION) { + // with CRC, we have got the entire item, so we need to get the ID out of that + STR_TO_LOCALID(itemP->getLocalID(),localid); } else { // without CRC, we have got the ID into itemLocalID already @@ -817,7 +817,7 @@ localstatus TBinfileImplDS::changeLogPreflight(bool &aValidChangelog) // - search for already existing changelog entry for this uniqueID // (prevent searching those that we have created in this preflight) bool chgentryexists=false; // none found yet - TChangeLogEntry *currentEntryP = NULL; // no entry yet + TChangeLogEntry *currentEntryP = NULL; // no entry yet for (logindex=0; logindex<numexistinglogentries; logindex++) { if (LOCALID_EQUAL(existingentries[logindex].dbrecordid,localid)) { // found @@ -828,7 +828,7 @@ localstatus TBinfileImplDS::changeLogPreflight(bool &aValidChangelog) currentEntryP->flags &= ~chgl_delete_candidate; // remove candidate flag } // found - if (CRC_CHANGE_DETECTION) { + if (CRC_CHANGE_DETECTION) { PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI+DBG_EXOTIC,( "- found in changelog at index=%ld, flags=0x%02hX, modcount=%ld, modcount_created=%ld, saved CRC=0x%04hX", (long)logindex, @@ -837,7 +837,7 @@ localstatus TBinfileImplDS::changeLogPreflight(bool &aValidChangelog) (long)currentEntryP->modcount_created, currentEntryP->dataCRC )); - } + } else { PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI+DBG_EXOTIC,( "- found in changelog at index=%ld, flags=0x%02hX, modcount=%ld, modcount_created=%ld", @@ -865,9 +865,9 @@ localstatus TBinfileImplDS::changeLogPreflight(bool &aValidChangelog) } // now check what to do if (CRC_CHANGE_DETECTION) { - #ifndef RECORDHASH_FROM_DBAPI - // we need a CRC but don't have it precalculated from the DB layer - dataCRC=itemP->getDataCRC(0,true); // start new CRC, do not include eqm_none fields + #ifndef RECORDHASH_FROM_DBAPI + // we need a CRC but don't have it precalculated from the DB layer + dataCRC=itemP->getDataCRC(0,true); // start new CRC, do not include eqm_none fields #endif // not RECORDHASH_FROM_DBAPI } // - check if new or changed @@ -910,7 +910,7 @@ localstatus TBinfileImplDS::changeLogPreflight(bool &aValidChangelog) fNumberOfLocalChanges++; // for suspend: those that detect a change here were modified AFTER last suspend, so always count them } } - if (!itemIsModified) { + if (!itemIsModified) { // no change detected since last preflight (but still, this could be a change to report to the server) if (isResuming()) { // if resuming - only those count that are marked for resume @@ -933,27 +933,27 @@ localstatus TBinfileImplDS::changeLogPreflight(bool &aValidChangelog) currentEntryP->modcount_created = fCurrentModCount; // - no flags set currentEntryP->flags = 0; - // - update CRC to current value if CRC is in use - if (CRC_CHANGE_DETECTION) { - currentEntryP->dataCRC = dataCRC; + // - update CRC to current value if CRC is in use + if (CRC_CHANGE_DETECTION) { + currentEntryP->dataCRC = dataCRC; } else { - currentEntryP->dataCRC = 0; // clean it for cosmetic reasons only + currentEntryP->dataCRC = 0; // clean it for cosmetic reasons only } - // create if entry is new + // create if entry is new if (!chgentryexists) { - // this is a new, additional entry (and not a resurrected deleted one) - fChangeLog.newRecord(currentEntryP); - PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI,("- item was newly added (no entry existed in changelog before)")); + // this is a new, additional entry (and not a resurrected deleted one) + fChangeLog.newRecord(currentEntryP); + PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI,("- item was newly added (no entry existed in changelog before)")); } else { - // the entry itself existed, but was a deleted entry. We're now re-using that one - PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI,("- item has re-appeared (i.e. item with same local uniqueID that was once before deleted is now here again)")); + // the entry itself existed, but was a deleted entry. We're now re-using that one + PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI,("- item has re-appeared (i.e. item with same local uniqueID that was once before deleted is now here again)")); } // this is a local change for this session (even for resume - we need to add newly added ones in resume!) fNumberOfLocalChanges++; } - // Next item + // Next item if (CRC_CHANGE_DETECTION) { #ifdef RECORDHASH_FROM_DBAPI foundone = getNextItemCRC(itemLocalID,dataCRC); @@ -965,8 +965,8 @@ localstatus TBinfileImplDS::changeLogPreflight(bool &aValidChangelog) #endif } else { - #ifdef CHANGEDETECTION_AVAILABLE - foundone = getNextItemInfo(itemLocalID,itemIsModified); + #ifdef CHANGEDETECTION_AVAILABLE + foundone = getNextItemInfo(itemLocalID,itemIsModified); #endif } } // while all records in DB @@ -1070,7 +1070,7 @@ localstatus TBinfileImplDS::loadTarget(bool aCreateIfMissing, cAppCharP aRemoteD } } } - // target not found + // target not found if (aCreateIfMissing) { // create new target record // - init with defaults @@ -1096,12 +1096,12 @@ localstatus TBinfileImplDS::loadTarget(bool aCreateIfMissing, cAppCharP aRemoteD // in client case. sInt32 TBinfileImplDS::getNumberOfChanges(void) { - if (binfileDSActive() && IS_CLIENT) { - // for client case with active binfile, we return the locally computed count + if (binfileDSActive() && IS_CLIENT) { + // for client case with active binfile, we return the locally computed count // (for server, the entire list of changes is loaded by the baseclass // before NOC is needed, so the baseclass has the more accurate count // which takes filtering etc. into account). - return fNumberOfLocalChanges; + return fNumberOfLocalChanges; } // otherwise, let base class handle it (server and client w/o binfile) return inherited::getNumberOfChanges(); @@ -1122,7 +1122,7 @@ localstatus TBinfileImplDS::implMakeAdminReady( cAppCharP aRemoteDBID // database ID of remote device ) { - if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all + if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all localstatus sta=LOCERR_OK; // assume ok @@ -1135,12 +1135,12 @@ localstatus TBinfileImplDS::implMakeAdminReady( #if !defined(PRECONFIGURED_SYNCREQUESTS) // when sync params are in binfiles, target must be present by now - make sure it is loaded - sta=loadTarget(false); + sta=loadTarget(false); // target info must already be present by now (loaded at session's SelectProfile) if (sta!=LOCERR_OK || fTargetIndex<0) { - // problem loading target record - sta = sta ? sta : 404; - PDEBUGPRINTFX(DBG_ERROR,("Error %d loading target record",sta)); + // problem loading target record + sta = sta ? sta : 404; + PDEBUGPRINTFX(DBG_ERROR,("Error %d loading target record",sta)); PDEBUGENDBLOCK("implMakeAdminReady"); return sta; } @@ -1202,22 +1202,22 @@ localstatus TBinfileImplDS::implMakeAdminReady( #ifdef SYDEBUG string lsd; StringObjTimestamp(lsd,fPreviousToRemoteSyncCmpRef); - PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI,("- last preflight update (fPreviousToRemoteSyncCmpRef) at %s",lsd.c_str())); + PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI,("- last preflight update (fPreviousToRemoteSyncCmpRef) at %s",lsd.c_str())); #endif // SYDEBUG #if TARGETS_DB_VERSION>=6 // - DB api level change detection identifiers fPreviousToRemoteSyncIdentifier.assign(fChgLogHeader.lastChangeCheckIdentifier); fPreviousSuspendIdentifier = fPreviousToRemoteSyncIdentifier; // DB on top of binfile only needs one reference time, which is the last changelog check time. - PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI,("- last preflight update (fPreviousToRemoteSyncIdentifier) is '%s'",fPreviousToRemoteSyncIdentifier.c_str())); + PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI,("- last preflight update (fPreviousToRemoteSyncIdentifier) is '%s'",fPreviousToRemoteSyncIdentifier.c_str())); #endif // TARGETS_DB_VERSION>=6 - } + } } // get pending maps anyway (even if not resuming there might be pending maps) if(openPendingMaps()) { // there is a pending map file, check if these are really our maps // Note: with separated changelogs, this should be always the case! PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI+DBG_EXOTIC,( - "implMakeAdminReady: remotePartyID of pendingmaps=%ld, current profile's remotepartyID=%ld", + "implMakeAdminReady: remotePartyID of pendingmaps=%ld, current profile's remotepartyID=%ld", (long)fPendingMapHeader.remotepartyID, (long)static_cast<TBinfileImplClient *>(fSessionP)->fRemotepartyID )); @@ -1289,7 +1289,7 @@ localstatus TBinfileImplDS::implMakeAdminReady( localstatus TBinfileImplDS::implStartDataRead() { - if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all + if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all // init reading of all records // - start at beginning of log @@ -1324,7 +1324,7 @@ bool TBinfileImplDS::testFilters(TMultiFieldItem *aItemP) /// @brief called to have all non-yet-generated sync commands as "to-be-resumed" void TBinfileImplDS::implMarkOnlyUngeneratedForResume(void) { - if (!binfileDSActive()) return; // must be active when called at all + if (!binfileDSActive()) return; // must be active when called at all TChangeLogEntry *chglogP; @@ -1410,7 +1410,7 @@ void TBinfileImplDS::implMarkOnlyUngeneratedForResume(void) // as "to-be-resumed", by localID or remoteID (latter only in server case). void TBinfileImplDS::implMarkItemForResume(cAppCharP aLocalID, cAppCharP aRemoteID, bool aUnSent) { - if (!binfileDSActive()) return; // must be active when called at all + if (!binfileDSActive()) return; // must be active when called at all // make sure we have the changelog in memory loadChangeLog(); @@ -1445,7 +1445,7 @@ void TBinfileImplDS::implMarkItemForResume(cAppCharP aLocalID, cAppCharP aRemote // error status conditions, by localID or remoteID (latter only in server case). void TBinfileImplDS::implMarkItemForResend(cAppCharP aLocalID, cAppCharP aRemoteID) { - if (!binfileDSActive()) return; // must be active when called at all + if (!binfileDSActive()) return; // must be active when called at all // make sure we have the changelog in memory loadChangeLog(); @@ -1484,7 +1484,7 @@ localstatus TBinfileImplDS::implGetItem( TSyncItem* &aSyncItemP ) { - if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all + if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all localstatus sta=LOCERR_OK; TSyncItem *myitemP=NULL; @@ -1616,13 +1616,13 @@ localstatus TBinfileImplDS::implGetItem( // this entry is to be reported // - now check how to report if (chglogP->flags & chgl_deleted) { - // deleted: only report if it is also changed (i.e. delete detected since last sync) + // deleted: only report if it is also changed (i.e. delete detected since last sync) // Note: this can only happen when caller requests to see all records, not only changed, // which usually only occurs in slowsync where deletes are NOT reported anyway. // However: when caller must dynamically filter the syncset, it will request all records // even in normal syncs and then this can happen. if (!aChanged) - continue; // delete was reported earlier, don't report it again + continue; // delete was reported earlier, don't report it again // deleted, we cannot get it from the DB, create a empty item myitemP = new TSyncItem(); // add ID @@ -1651,14 +1651,14 @@ localstatus TBinfileImplDS::implGetItem( } // detect wheter the item is new added or changed if(chglogP->modcount_created > fPreviousToRemoteModCount) { - // Added + // Added myitemP->setSyncOp(sop_add); } else { - // Not added (changed or just reported because we want all records reported) + // Not added (changed or just reported because we want all records reported) // - if enabled, also verify change by checking CRC before reporting it (unless this is a slow sync) - if (CRC_DETECT_PSEUDOCHANGES && aChanged) { - // check if really changed using CRC, but only... + if (CRC_DETECT_PSEUDOCHANGES && aChanged) { + // check if really changed using CRC, but only... // ...if not slow sync (all items must be reported) // ...if change was detected in this session's preflight. If the change was detected earlier and is still // pending (i.e. newer than the last sync), this means that this change might have failed to be applied @@ -1668,22 +1668,22 @@ localstatus TBinfileImplDS::implGetItem( // suppressed, but in case this sync fails, subsequent syncs will report it. uInt16 newDataCRC = myitemP->getDataCRC(0,true); PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI+DBG_EXOTIC,( - "CRC comparison for pseudo-change detection: old CRC=0x%hX, new CRC=0x%hX, recordModCount=%u, currentModCount=%u", + "CRC comparison for pseudo-change detection: old CRC=0x%hX, new CRC=0x%hX, recordModCount=%u, currentModCount=%u", chglogP->dataCRC, newDataCRC, chglogP->modcount, fCurrentModCount )); - if (chglogP->dataCRC==newDataCRC && !fSlowSync && chglogP->modcount==fCurrentModCount) { - // none of the relevant fields have changed -> don't report the item + if (chglogP->dataCRC==newDataCRC && !fSlowSync && chglogP->modcount==fCurrentModCount) { + // none of the relevant fields have changed -> don't report the item PDEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI,("Not reporting localID='%s' as changed because CRC detected this as a pseudo-change.",myitemP->getLocalID())); aChanged = false; // even if it gets reported, it does not count as changed any more if (onlyChanged) { - // we don't need to report this at all, as we only report changed ones + // we don't need to report this at all, as we only report changed ones delete myitemP; // delete the item continue; // don't report, try next } // report as unchanged } else { - // change will now be reported, so update CRC to what we report now + // change will now be reported, so update CRC to what we report now // Note: the problem with this is that in case the sync does not succeed now, the CRC is already updated and would // trigger pseudo-change detection in the next session. Therefore, pseudo-change detection is only active for // changes newly detected during this sync. @@ -1726,7 +1726,7 @@ error: // end of read localstatus TBinfileImplDS::implEndDataRead(void) { - if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all + if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all // pass it on to the DB api (usually dummy for traditional binfile derivates, but // needed for customimplds) @@ -1781,7 +1781,7 @@ void TBinfileImplDS::loadChangeLog(void) // start of write localstatus TBinfileImplDS::implStartDataWrite(void) { - if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all + if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all localstatus sta = LOCERR_OK; @@ -1810,13 +1810,13 @@ localstatus TBinfileImplDS::implStartDataWrite(void) #ifdef ZAP_FORCES_SLOWSYNC // we force a slowsync, zap the changelog fChangeLog.truncate(0); - // forget the anchor to force a slow sync anyway + // forget the anchor to force a slow sync anyway fTarget.remoteAnchor[0]=0; // (only to make sure. If sync completes successfully, this will be updated anyway in SaveAnchor) - // for combined changelog, we need to take care of other profiles + // for combined changelog, we need to take care of other profiles if (!static_cast<TBinfileClientConfig *>(fSessionP->getSessionConfig())->fSeparateChangelogs) { - // zap the anchors in all other profiles for this datastore - // because we have deleted the (common) changelog. Note that this also resets our own - // target's anchor (again) + // zap the anchors in all other profiles for this datastore + // because we have deleted the (common) changelog. Note that this also resets our own + // target's anchor (again) // get target DB TBinFile *targetsBinFileP = &(static_cast<TBinfileImplClient *>(fSessionP)->fConfigP->fTargetsBinFile); TBinfileDBSyncTarget target; @@ -1864,7 +1864,7 @@ bool TBinfileImplDS::implRetrieveItemByID( TStatusCommand &aStatusCommand ) { - if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all + if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all // %%% not so nice as we need to copy it once TSyncItem *itemP=NULL; // read item by local ID @@ -1898,7 +1898,7 @@ bool TBinfileImplDS::implProcessItem( TStatusCommand &aStatusCommand ) { - if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all + if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all localid_out_t newid; TSyError statuscode; @@ -2028,7 +2028,7 @@ bool TBinfileImplDS::implProcessItem( // new added item ASSIGN_LOCALID_TO_FLD(affectedentryP->dbrecordid,localid); // also record the time this entry was created - affectedentryP->modcount_created=fCurrentModCount; + affectedentryP->modcount_created=fCurrentModCount; // save it #ifdef NUMERIC_LOCALIDS DEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI+DBG_EXOTIC,( @@ -2083,7 +2083,7 @@ done: // @note aSyncOp passed not necessarily reflects what was sent to remote, but what actually happened void TBinfileImplDS::dsConfirmItemOp(TSyncOperation aSyncOp, cAppCharP aLocalID, cAppCharP aRemoteID, bool aSuccess, localstatus aErrorStatus) { - if (binfileDSActive()) { + if (binfileDSActive()) { // Nothing to do here, even successful deletes must not delete changelog entry (this will be done // by changeLogPostFlight() for those enties that have been reported as deleted in all profiles!) } @@ -2097,7 +2097,7 @@ void TBinfileImplDS::dsConfirmItemOp(TSyncOperation aSyncOp, cAppCharP aLocalID, // (or, in case the session is really complete, make sure that no resume state is left) localstatus TBinfileImplDS::implSaveResumeMarks(void) { - if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all + if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all // update modcount reference of last suspend fPreviousSuspendModCount = fCurrentModCount; @@ -2111,10 +2111,10 @@ localstatus TBinfileImplDS::implSaveResumeMarks(void) // - Called at end of sync with this datastore void TBinfileImplDS::dsLogSyncResult(void) { - // Note: binfile logs can be active even if binfiles layer otherwise is not active - TBinfileClientConfig *clientCfgP = static_cast<TBinfileClientConfig *>(fSessionP->getSessionConfig()); - if (clientCfgP->fBinFileLog) { - // writing binfile logs enabled + // Note: binfile logs can be active even if binfiles layer otherwise is not active + TBinfileClientConfig *clientCfgP = static_cast<TBinfileClientConfig *>(fSessionP->getSessionConfig()); + if (clientCfgP->fBinFileLog) { + // writing binfile logs enabled TBinFile logFile; // Open logfile // - get base path @@ -2133,7 +2133,7 @@ void TBinfileImplDS::dsLogSyncResult(void) logInfo.time = fCurrentSyncTime; // current sync's time logInfo.status = getAbortStatusCode(); // reason for abort (0 if ok) logInfo.mode = - (fSlowSync ? (fFirstTimeSync ? 2 : 1) : 0) + + (fSlowSync ? (fFirstTimeSync ? 2 : 1) : 0) + (fResuming ? 10 : 0); logInfo.dirmode = fSyncMode; // sync direction mode logInfo.infoID = 0; // none @@ -2162,7 +2162,7 @@ void TBinfileImplDS::dsLogSyncResult(void) // be called by the derivate after doing customimpl specific stuff. localstatus TBinfileImplDS::implSaveEndOfSession(bool aUpdateAnchors) { - if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all + if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all // update TCustomImplDS dsSavedAdmin variables (other levels have already updated their variables if (aUpdateAnchors) { @@ -2182,16 +2182,16 @@ localstatus TBinfileImplDS::implSaveEndOfSession(bool aUpdateAnchors) uInt32 oldestmodcount=0xFFFFFFFF; // do a postFlight to remove unused entries from the changelog if (static_cast<TBinfileClientConfig *>(fSessionP->getSessionConfig())->fSeparateChangelogs) { - // Each profile has it's own changelog, so just delete entries that are older than this profile's last sync or resume + // Each profile has it's own changelog, so just delete entries that are older than this profile's last sync or resume if (fTarget.lastSuspendModCount!=0) - oldestmodcount = fTarget.lastSuspendModCount; + oldestmodcount = fTarget.lastSuspendModCount; if (fTarget.lastTwoWayModCount!=0 && fTarget.lastTwoWayModCount<oldestmodcount) - oldestmodcount = fTarget.lastTwoWayModCount; + oldestmodcount = fTarget.lastTwoWayModCount; } else { - // Combined changelog for all profiles, need to keep deleted markers for other profiles + // Combined changelog for all profiles, need to keep deleted markers for other profiles // - find oldest sync modcount - TBinFile *targetsBinFileP = &(static_cast<TBinfileImplClient *>(fSessionP)->fConfigP->fTargetsBinFile); + TBinFile *targetsBinFileP = &(static_cast<TBinfileImplClient *>(fSessionP)->fConfigP->fTargetsBinFile); uInt32 maxidx = targetsBinFileP->getNumRecords(); uInt32 idx; TBinfileDBSyncTarget target; @@ -2221,7 +2221,7 @@ localstatus TBinfileImplDS::implSaveEndOfSession(bool aUpdateAnchors) // - end write with commit bool TBinfileImplDS::implEndDataWrite(void) { - if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all + if (!binfileDSActive()) return LOCERR_WRONGUSAGE; // must be active when called at all // Call apiEndDataWrite variant which is possibly implemented in // datastores which were designed as direct derivates of binfileds. @@ -2277,7 +2277,7 @@ localstatus TBinfileImplDS::SaveAdminData(bool aSessionFinished, bool aSuccessfu // Note: preflight has already set fChgLogHeader.lastChangeCheck to the beginning of the sync // Update it here only if synctime must be end of session. if (fConfigP->fCmpRefTimeStampAtEnd) { - fChgLogHeader.lastChangeCheck = getSession()->getSystemNowAs(TCTX_UTC); // NOW ! (again); + fChgLogHeader.lastChangeCheck = getSession()->getSystemNowAs(TCTX_UTC); // NOW ! (again); } fChangeLog.setExtraHeaderDirty(); fChangeLog.flushHeader(); @@ -2321,7 +2321,7 @@ localstatus TBinfileImplDS::SaveAdminData(bool aSessionFinished, bool aSuccessfu /// @note: lastSuspendModCount is the same target field that previously was called "lastModCount" fTarget.lastSuspendModCount = fPreviousSuspendModCount; if (!static_cast<TBinfileClientConfig *>(fSessionP->getSessionConfig())->fSeparateChangelogs) { - // Combined changelogs: make sure that resume alert codes of all other profile's targets for this datastore are erased + // Combined changelogs: make sure that resume alert codes of all other profile's targets for this datastore are erased // (because in a single changelog there is only one set of markforresume flags and single pendingmap+pendingitem files) TBinfileDBSyncTarget otherTarget; memset(&otherTarget, 0, sizeof(otherTarget)); @@ -2358,7 +2358,7 @@ localstatus TBinfileImplDS::SaveAdminData(bool aSessionFinished, bool aSuccessfu // - now pending maps (unsent ones) DEBUGPRINTFX(DBG_ADMIN+DBG_DBAPI+DBG_DETAILS,("SaveAdminData: saving %ld entries from fPendingAddMap to fPendingMaps binfile",(long)fPendingAddMaps.size())); for (spos=fPendingAddMaps.begin();spos!=fPendingAddMaps.end();spos++) { - string locID = (*spos).first; + string locID = (*spos).first; dsFinalizeLocalID(locID); // pending maps might have non-final ID, so give datastore implementation to return finalized version STR_TO_LOCALID(locID.c_str(),localid); ASSIGN_LOCALID_TO_FLD(pme.dbrecordid,localid); AssignCString(pme.remoteID,(*spos).second.c_str(),BINFILE_MAXGUIDSIZE+1); diff --git a/src/sysync/itemfield.cpp b/src/sysync/itemfield.cpp index d28b52b..bb1e820 100644 --- a/src/sysync/itemfield.cpp +++ b/src/sysync/itemfield.cpp @@ -268,7 +268,7 @@ TArrayField::~TArrayField() bool TArrayField::elementsBasedOn(TItemFieldTypes aFieldType) const { - return fFirstField->isBasedOn(aFieldType); + return fFirstField->isBasedOn(aFieldType); } // TArrayField::elementsBasedOn @@ -300,9 +300,9 @@ TItemField *TArrayField::getArrayField(sInt16 aArrIdx, bool aExistingOnly) if (fldP==NULL) { // but element does not exist yet, create field for it if (aArrIdx==0) - fldP = fFirstField; + fldP = fFirstField; else - fldP = newItemField(fLeafFieldType,fGZonesP,false); + fldP = newItemField(fLeafFieldType,fGZonesP,false); fArray[aArrIdx]=fldP; } } @@ -345,8 +345,8 @@ void TArrayField::unAssign(void) { for (sInt16 idx=0; idx<arraySize(); idx++) { if (fArray[idx]) { - if (idx==0) - fArray[idx]->unAssign(); // first is always kept, it is the fFirstField, so only unassign to remove content + if (idx==0) + fArray[idx]->unAssign(); // first is always kept, it is the fFirstField, so only unassign to remove content else delete fArray[idx]; fArray[idx]=NULL; @@ -421,24 +421,24 @@ void TArrayField::appendString(cAppCharP aString, size_t aMaxChars) // contained somewhere in my own array) bool TArrayField::contains(TItemField &aItemField, bool aCaseInsensitive) { - bool contained = false; + bool contained = false; if (aItemField.isArray()) { - contained=true; - // array: all array elements must be contained in at least one of my elements + contained=true; + // array: all array elements must be contained in at least one of my elements for (sInt16 idx=0; idx<aItemField.arraySize(); idx++) { - if (!contains(*(aItemField.getArrayField(idx)),aCaseInsensitive)) { - // one of the elements of aItemField is not contained in myself -> not contained - contained = false; + if (!contains(*(aItemField.getArrayField(idx)),aCaseInsensitive)) { + // one of the elements of aItemField is not contained in myself -> not contained + contained = false; break; } } } else { - // leaf element: must be contained in at least one of my elements - contained = false; + // leaf element: must be contained in at least one of my elements + contained = false; for (sInt16 idx=0; idx<arraySize(); idx++) { if (getArrayField(idx)->contains(aItemField,aCaseInsensitive)) { - // the value of aItemField is contained in one of my elements -> contained + // the value of aItemField is contained in one of my elements -> contained contained = true; break; } @@ -1027,10 +1027,10 @@ TURLField::~TURLField() void TURLField::stringWasAssigned(void) { - // post-process string that was just assigned + // post-process string that was just assigned string proto; if (!fString.empty()) { - // make sure we have a URL with protocol + // make sure we have a URL with protocol splitURL(fString.c_str() ,&proto, NULL, NULL, NULL, NULL); if (proto.empty()) { // no protocol set, but string not empty --> assume http @@ -1258,7 +1258,7 @@ void TTimestampField::makeFloating(void) /// @return true if context has TCTX_DURATION rendering flag set bool TTimestampField::isDuration(void) { - return TCTX_IS_DURATION(fTimecontext); + return TCTX_IS_DURATION(fTimecontext); } // TTimestampField::isDuration @@ -2006,7 +2006,7 @@ TSyError TItemFieldKey::GetValueInternal( sInt16 minOffs; TTimestampField *tsFldP; if (aID & VALID_FLAG_NORM) { - // for all field types: get normalized string value + // for all field types: get normalized string value fieldP->getAsNormalizedString(sval); aValSize = sval.size(); valPtr = (appPointer)sval.c_str(); @@ -2119,12 +2119,12 @@ TSyError TItemFieldKey::SetValueInternal( TTimestampField *tsFldP; // treat setting normalized value like setting as string if (aID & VALID_FLAG_NORM) - fty = fty_string; // treat like string + fty = fty_string; // treat like string // handle NULL (empty) case if (aBuffer==0) { - // buffer==NULL means NULL value - fieldP->assignEmpty(); - return LOCERR_OK; + // buffer==NULL means NULL value + fieldP->assignEmpty(); + return LOCERR_OK; } // now handle according to type switch (fty) { diff --git a/src/sysync/itemfield.h b/src/sysync/itemfield.h index 468d831..d342ef7 100755 --- a/src/sysync/itemfield.h +++ b/src/sysync/itemfield.h @@ -319,7 +319,7 @@ public: virtual size_t StringObjFieldAppend(string &s, uInt16 aMaxStrLen); #endif protected: - virtual void stringWasAssigned(void) { fAssigned=true; }; // post-process string that was just assigned + virtual void stringWasAssigned(void) { fAssigned=true; }; // post-process string that was just assigned #ifdef STREAMFIELD_SUPPORT TBlobProxy *fBlobProxyP; #endif @@ -678,8 +678,8 @@ private: #endif // ENGINEINTERFACE_SUPPORT -} // namespace sysync +} // namespace sysync -#endif // ItemField_H +#endif // ItemField_H // eof diff --git a/src/sysync/localengineds.cpp b/src/sysync/localengineds.cpp index 42483f7..dabddf7 100644 --- a/src/sysync/localengineds.cpp +++ b/src/sysync/localengineds.cpp @@ -462,16 +462,16 @@ public: TLocalEngineDS *dsP = static_cast<TLocalEngineDS *>(aFuncContextP->getCallerContext()); // put into record level filter if (dsP->getSession()->getSyncMLVersion()>=syncml_vers_1_2) { - // DS 1.2: use <filter> - aFuncContextP->getLocalVar(0)->getAsString(dsP->fRemoteRecordFilterQuery); - dsP->fRemoteFilterInclusive = aFuncContextP->getLocalVar(1)->getAsBoolean(); + // DS 1.2: use <filter> + aFuncContextP->getLocalVar(0)->getAsString(dsP->fRemoteRecordFilterQuery); + dsP->fRemoteFilterInclusive = aFuncContextP->getLocalVar(1)->getAsBoolean(); } else if (!aFuncContextP->getLocalVar(0)->isEmpty()) { - // DS 1.1 and below and not empty filter: add as cgi + // DS 1.1 and below and not empty filter: add as cgi string filtercgi; if (aFuncContextP->getLocalVar(1)->getAsBoolean()) filtercgi = "/tf("; // exclusive, use TAF - else + else filtercgi = "/fi("; // inclusive, use sync set filter aFuncContextP->getLocalVar(0)->appendToString(filtercgi); filtercgi += ')'; @@ -776,14 +776,14 @@ bool TTypeSupportConfig::localStartElement(const char *aElementName, const char bool preferred=false; const char* pref = getAttr(aAttributes,"preferred"); if (pref) { - if (!StrToBool(pref, preferred)) { - if (strucmp(pref,"legacy")==0) { - // this is the preferred type for blind and legacy mode sync attempts + if (!StrToBool(pref, preferred)) { + if (strucmp(pref,"legacy")==0) { + // this is the preferred type for blind and legacy mode sync attempts fPreferredLegacy=typecfgP; // remember (note that there is only ONE preferred type, mode is ignored) - preferred=false; // not officially preferred + preferred=false; // not officially preferred } - else - return fail("bad value for 'preferred'"); + else + return fail("bad value for 'preferred'"); } } // now add datatype @@ -948,13 +948,13 @@ bool TLocalDSConfig::localStartElement(const char *aElementName, const char **aA else if (strucmp(aElementName,"alwayssendlocalid")==0) expectBool(fAlwaysSendLocalID); else if (strucmp(aElementName,"alias")==0) { - // get a name + // get a name string name; - if (!getAttrExpanded(aAttributes, "name", name, true)) + if (!getAttrExpanded(aAttributes, "name", name, true)) return fail("Missing 'name' attribute in 'alias'"); fAliasNames.push_back(name); expectEmpty(); - } + } #endif else if (strucmp(aElementName,"maxitemspermessage")==0) expectUInt32(fMaxItemsPerMessage); @@ -1117,11 +1117,11 @@ void TLocalDSConfig::addTypeLimits(TLocalEngineDS *aLocalDatastoreP, TSyncSessio // Check for alias names uInt16 TLocalDSConfig::isDatastoreAlias(cAppCharP aDatastoreURI) { - // only servers have (and may need) aliases - #ifdef SYSYNC_SERVER + // only servers have (and may need) aliases + #ifdef SYSYNC_SERVER for (TStringList::iterator pos = fAliasNames.begin(); pos!=fAliasNames.end(); pos++) { - if (*pos == aDatastoreURI) - return (*pos).size(); // return size of match + if (*pos == aDatastoreURI) + return (*pos).size(); // return size of match } #endif return 0; @@ -1202,7 +1202,7 @@ void TLocalEngineDS::InternalResetDataStore(void) fTempGUIDMap.clear(); #endif - /// Init type negotiation + /// Init type negotiation /// - for sending data fLocalSendToRemoteTypeP = NULL; fRemoteReceiveFromLocalTypeP = NULL; @@ -1212,7 +1212,7 @@ void TLocalEngineDS::InternalResetDataStore(void) /// Init Filtering @ref dsFiltering resetFiltering(); - + /// Init item processing @ref dsItemProcessing fSessionConflictStrategy=cr_duplicate; // will be updated later when sync mode is known fItemSizeLimit=-1; // no limit yet @@ -1351,8 +1351,8 @@ uInt16 TLocalEngineDS::isDatastore(const char *aDatastoreURI) // - compare with main name int res = inherited::isDatastore(basename.c_str()); if (res==0) { - // Not main name: compare with aliases - res = fDSConfigP->isDatastoreAlias(basename.c_str()); + // Not main name: compare with aliases + res = fDSConfigP->isDatastoreAlias(basename.c_str()); } return res; } // TLocalEngineDS::isDatastore @@ -1367,7 +1367,7 @@ string TLocalEngineDS::lastDBErrorText(void) s.erase(); uInt32 err = lastDBError(); if (isDBError(err)) { - StringObjPrintf(s," (DB specific error code = %ld)",(long)lastDBError()); + StringObjPrintf(s," (DB specific error code = %ld)",(long)lastDBError()); } return s; } // TLocalEngineDS::lastDBErrorText @@ -1393,37 +1393,37 @@ bool TLocalEngineDS::dsSetClientSyncParams( fRemoteDBPath=aRemoteDBPath; AssignString(fDBUser,aDBUser); AssignString(fDBPassword,aDBPassword); - // check for running under control of a superdatastore + // check for running under control of a superdatastore // - aRemoteDBPath might contain a special prefix: "<super>remote", with "super" specifying the // name of a local superdatastore to run the sync with string opts; - if (!fRemoteDBPath.empty() && fRemoteDBPath.at(0)=='<') { - // we have an option prefix + if (!fRemoteDBPath.empty() && fRemoteDBPath.at(0)=='<') { + // we have an option prefix size_t pfxe = fRemoteDBPath.find('>', 1); if (pfxe!=string::npos) { - // extract options - opts.assign(fRemoteDBPath, 1, pfxe-1); + // extract options + opts.assign(fRemoteDBPath, 1, pfxe-1); // store remote path cleaned from options fRemoteDBPath.erase(0,pfxe+1); } } if (!opts.empty()) { - #ifdef SUPERDATASTORES - // For now, the only option withing angle brackets is the name of the superdatastore, so opts==superdatastorename - // - look for superdatastore having the specified name + #ifdef SUPERDATASTORES + // For now, the only option withing angle brackets is the name of the superdatastore, so opts==superdatastorename + // - look for superdatastore having the specified name TSuperDSConfig *superdscfgP = static_cast<TSuperDSConfig *>(getSession()->getSessionConfig()->getLocalDS(opts.c_str())); if (superdscfgP && superdscfgP->isAbstractDatastore()) { - // see if we have an instance of this already + // see if we have an instance of this already fAsSubDatastoreOf = static_cast<TSuperDataStore *>(getSession()->findLocalDataStore(superdscfgP)); if (fAsSubDatastoreOf) { - // that superdatastore already exists, just override client sync params with those already set - aSyncMode = fAsSubDatastoreOf->fSyncMode; - aSlowSync = fAsSubDatastoreOf->fSlowSync; + // that superdatastore already exists, just override client sync params with those already set + aSyncMode = fAsSubDatastoreOf->fSyncMode; + aSlowSync = fAsSubDatastoreOf->fSlowSync; aRecordFilterQuery = fAsSubDatastoreOf->fRemoteRecordFilterQuery.c_str(); } else { - // instantiate new superdatastore - fAsSubDatastoreOf = static_cast<TSuperDataStore *>(superdscfgP->newLocalDataStore(getSession())); + // instantiate new superdatastore + fAsSubDatastoreOf = static_cast<TSuperDataStore *>(superdscfgP->newLocalDataStore(getSession())); if (fAsSubDatastoreOf) { fSessionP->fLocalDataStores.push_back(fAsSubDatastoreOf); // configure it with the same parameters as the subdatastore @@ -1437,32 +1437,32 @@ bool TLocalEngineDS::dsSetClientSyncParams( aRecordFilterQuery, aFilterInclusive )) - return false; // failed + return false; // failed } } if (fAsSubDatastoreOf) { - // find link config for this superdatastore + // find link config for this superdatastore TSubDSLinkConfig *lcfgP = NULL; TSubDSConfigList::iterator pos; for(pos=superdscfgP->fSubDatastores.begin();pos!=superdscfgP->fSubDatastores.end();pos++) { - if ((*pos)->fLinkedDSConfigP==fDSConfigP) { - // this is the link + if ((*pos)->fLinkedDSConfigP==fDSConfigP) { + // this is the link lcfgP = *pos; break; } } if (lcfgP) { // now link into superdatastore - fAsSubDatastoreOf->addSubDatastoreLink(lcfgP,this); + fAsSubDatastoreOf->addSubDatastoreLink(lcfgP,this); } else { PDEBUGPRINTFX(DBG_ERROR,("Warning: '%s' is not a subdatastore of '%s'", getName(), opts.c_str())); - return false; // failed - } + return false; // failed + } } } else { - PDEBUGPRINTFX(DBG_ERROR,("Warning: No superdatastore name '%s' exists -> can't run '%s' under superdatastore control", opts.c_str(), getName())); + PDEBUGPRINTFX(DBG_ERROR,("Warning: No superdatastore name '%s' exists -> can't run '%s' under superdatastore control", opts.c_str(), getName())); return false; // failed } #endif // SUPERDATASTORES @@ -1688,7 +1688,7 @@ void TLocalEngineDS::addFilterCapPropsAndKeywords(SmlPcdataListPtr_t &aFilterKey // reset all filter settings void TLocalEngineDS::resetFiltering(void) { - #ifdef OBJECT_FILTERING + #ifdef OBJECT_FILTERING // - dynamic sync set filter fSyncSetFilter.erase(); // - static filter @@ -2138,7 +2138,7 @@ localstatus TLocalEngineDS::engParseOptions( if (aTargetURIOptions) { const char *p = aTargetURIOptions; #ifdef SYSYNC_TARGET_OPTIONS - const char *q; + const char *q; #endif char c; string taf; // official TAF @@ -2426,7 +2426,7 @@ TAlertCommand *TLocalEngineDS::engProcessSyncAlert( if (IS_SERVER) { // make sure we are not carrying forward any left-overs. Last sessions's tempGUID mappings that are // needed for "early map" resolution might be loaded by the call to engInitSyncAnchors below. - // IMPORTANT NOTE: the tempGUIDs that might get loaded will become invalid as soon as <Sync> + // IMPORTANT NOTE: the tempGUIDs that might get loaded will become invalid as soon as <Sync> // starts - so fTempGUIDMap needs to be cleared again as soon as the first <Sync> command arrives from the client. fTempGUIDMap.clear(); } @@ -2561,10 +2561,10 @@ TAlertCommand *TLocalEngineDS::engProcessSyncAlert( // Sync type supported // - set new state to alerted if (IS_CLIENT) { - changeState(dssta_clientalerted,true); // force it + changeState(dssta_clientalerted,true); // force it } else { - changeState(dssta_serveralerted,true); // force it + changeState(dssta_serveralerted,true); // force it } // - datastore state is now dss_alerted PDEBUGPRINTFX(DBG_HOT,( @@ -2593,7 +2593,7 @@ TAlertCommand *TLocalEngineDS::engProcessSyncAlert( ( ( (!fLastRemoteAnchor.empty() && - ( (fLastRemoteAnchor==aLastRemoteAnchor) + ( (fLastRemoteAnchor==aLastRemoteAnchor) #ifdef SYSYNC_CLIENT || (fSessionP->fLenientMode && IS_CLIENT) #endif @@ -2605,8 +2605,8 @@ TAlertCommand *TLocalEngineDS::engProcessSyncAlert( ) || fSlowSync // if slow sync is requested by the remote anyway, we don't need to be in sync anyway, so just go on ) { - if (!(fLastRemoteAnchor==aLastRemoteAnchor) && fSessionP->fLenientMode) { - PDEBUGPRINTFX(DBG_ERROR,("Warning - remote anchor mismatch but tolerated in lenient mode")); + if (!(fLastRemoteAnchor==aLastRemoteAnchor) && fSessionP->fLenientMode) { + PDEBUGPRINTFX(DBG_ERROR,("Warning - remote anchor mismatch but tolerated in lenient mode")); } // sync state ok or Slow sync requested anyway: #ifdef SYSYNC_SERVER @@ -2716,7 +2716,7 @@ TAlertCommand *TLocalEngineDS::engProcessSyncAlert( // (for sending same URI back in own Sync) fRemoteViewOfLocalURI = aTargetURI; // save it if (IS_SERVER) { - fRemoteDBPath = aSourceURI; + fRemoteDBPath = aSourceURI; } if (sta!=LOCERR_OK) { // no alert command @@ -2745,7 +2745,7 @@ bool TLocalEngineDS::engHandleAlertStatus(TSyError aStatusCode) if (!testState(dssta_clientsentalert,true)) return false; // cannot switch if server not alerted // anyway, we have seen the status changeState(dssta_clientalertstatused,true); // force it - } + } else { // for server, check if client did combined init&sync if (fLocalDSState>=dssta_syncmodestable) { @@ -2871,16 +2871,16 @@ localstatus TLocalEngineDS::engInitForSyncOps( } // default data types are those preferred by local datastore (or explicitly marked for blind sync attempts) if (getDSConfig()->fTypeSupport.fPreferredLegacy) { - // we have a preferred type for blind sync attempts - LocalSendToRemoteTypeP = getSession()->findLocalType(getDSConfig()->fTypeSupport.fPreferredLegacy); + // we have a preferred type for blind sync attempts + LocalSendToRemoteTypeP = getSession()->findLocalType(getDSConfig()->fTypeSupport.fPreferredLegacy); LocalReceiveFromRemoteTypeP = LocalSendToRemoteTypeP; } else { - // no specific "blind" preference, use my own normally preferred types - LocalSendToRemoteTypeP = getPreferredTxItemType(); // send in preferred tx type of local datastore - LocalReceiveFromRemoteTypeP = getPreferredRxItemType(); // receive in preferred rx type of local datastore + // no specific "blind" preference, use my own normally preferred types + LocalSendToRemoteTypeP = getPreferredTxItemType(); // send in preferred tx type of local datastore + LocalReceiveFromRemoteTypeP = getPreferredRxItemType(); // receive in preferred rx type of local datastore } - // same type on both end (as only local type exists) + // same type on both end (as only local type exists) RemoteReceiveFromLocalTypeP = LocalSendToRemoteTypeP; // same on both end RemoteSendToLocalTypeP = LocalReceiveFromRemoteTypeP; // same on both end (as only local type exists) // create "remote" datastore with matching properties to local one @@ -3031,11 +3031,11 @@ bool TLocalEngineDS::engGenerateSyncCommands( bool finished=false; #ifdef SYSYNC_CLIENT if (IS_CLIENT) - finished = logicGenerateSyncCommandsAsClient(aNextMessageCommands, aInterruptedCommandP, aLocalIDPrefix); + finished = logicGenerateSyncCommandsAsClient(aNextMessageCommands, aInterruptedCommandP, aLocalIDPrefix); #endif #ifdef SYSYNC_SERVER if (IS_SERVER) - finished = logicGenerateSyncCommandsAsServer(aNextMessageCommands, aInterruptedCommandP, aLocalIDPrefix); + finished = logicGenerateSyncCommandsAsServer(aNextMessageCommands, aInterruptedCommandP, aLocalIDPrefix); #endif // change state when finished if (finished) { @@ -3120,8 +3120,8 @@ bool TLocalEngineDS::engHandleSyncOpStatus(TStatusCommand *aStatusCmdP,TSyncOpCo case sop_wants_add: case sop_add: if (statuscode<300 || statuscode==419) { - // All ok status 2xx as well as special "merged" 419 is ok for an add: - // Whatever remote said, I know this is an add and so I counts this as such + // All ok status 2xx as well as special "merged" 419 is ok for an add: + // Whatever remote said, I know this is an add and so I counts this as such // (even if the remote somehow merged it with existing data, // it is obviously a new item in my sync set with this remote) fRemoteItemsAdded++; @@ -3357,7 +3357,7 @@ localstatus TLocalEngineDS::engPrepareClientSyncAlert(void) // no operation here if running under control of a superdatastore. // superdatastore's engPrepareClientSyncAlert() will call engPrepareClientRealDSSyncAlert of all subdatastores at the right time if (fAsSubDatastoreOf) - return LOCERR_OK; + return LOCERR_OK; #endif // this is a real datastore return engPrepareClientDSForAlert(); @@ -3370,7 +3370,7 @@ localstatus TLocalEngineDS::engPrepareClientDSForAlert(void) { localstatus sta; - // reset the filters that might be added to in alertprepscript + // reset the filters that might be added to in alertprepscript // (as they might have been half set-up in a previous failed alert, they must be cleared and re-constructed here) resetFiltering(); @@ -3527,23 +3527,23 @@ localstatus TLocalEngineDS::engGenerateClientSyncAlert( // - determine types to exchange // - make sync set ready localstatus TLocalEngineDS::engInitForClientSync(void) -{ +{ #ifdef SUPERDATASTORES // no init in case we are under control of a superdatastore -> the superdatastore will do that if (fAsSubDatastoreOf) - return LOCERR_OK; + return LOCERR_OK; #endif return engInitDSForClientSync(); } // TLocalEngineDS::engInitForClientSync - + // Init engine for client sync // - determine types to exchange // - make sync set ready localstatus TLocalEngineDS::engInitDSForClientSync(void) { - // make ready for syncops + // make ready for syncops localstatus sta = engInitForSyncOps(getRemoteDBPath()); if (sta==LOCERR_OK) { // - let local datastore (derived DB-specific class) prepare for sync @@ -3786,7 +3786,7 @@ SmlDevInfDatastorePtr_t TLocalEngineDS::newDevInfDatastore(bool aAsServer, bool // - check for legacy mode type (that is to be used as "preferred" instead of normal preferred) TSyncItemType *legacyTypeP = NULL; if (getSession()->fLegacyMode && getDSConfig()->fTypeSupport.fPreferredLegacy) { - // get the type marked as blind + // get the type marked as blind legacyTypeP = getSession()->findLocalType(getDSConfig()->fTypeSupport.fPreferredLegacy); } // - RxPref @@ -4065,7 +4065,7 @@ void TLocalEngineDS::engEndOfSyncFromRemote(bool aEndOfAllSyncCommands) } #ifdef SYSYNC_SERVER if (IS_SERVER) { - engServerStartOfSyncMessage(); + engServerStartOfSyncMessage(); } #endif // now do final things @@ -4210,7 +4210,7 @@ void TLocalEngineDS::engAbortDataStoreSync(TSyError aStatusCode, bool aLocalProb aStatusCode )); DB_PROGRESS_EVENT( - this, + this, pev_syncend, getAbortStatusCode(), fSlowSync ? (fFirstTimeSync ? 2 : 1) : 0, @@ -4380,7 +4380,7 @@ void TLocalEngineDS::engFinishDataStoreSync(localstatus aErrorStatus) engAbortDataStoreSync(aErrorStatus,true); // if we have an error here, this is considered a local problem else { DB_PROGRESS_EVENT( - this, + this, pev_syncend, fAbortStatusCode, fSlowSync ? (fFirstTimeSync ? 2 : 1) : 0, @@ -4478,10 +4478,10 @@ void TLocalEngineDS::showStatistics(void) // successful: show statistics on console CONSOLEPRINTF((" ==================================================")); if (IS_SERVER) { - CONSOLEPRINTF((" on Server on Client")); + CONSOLEPRINTF((" on Server on Client")); } else { - CONSOLEPRINTF((" on Client on Server")); + CONSOLEPRINTF((" on Client on Server")); } CONSOLEPRINTF((" Added: %9ld %9ld",fLocalItemsAdded,fRemoteItemsAdded)); CONSOLEPRINTF((" Deleted: %9ld %9ld",fLocalItemsDeleted,fRemoteItemsDeleted)); @@ -4520,10 +4520,10 @@ void TLocalEngineDS::showStatistics(void) string stats = "==================================================\n"; if (IS_SERVER) { - stats += " on Server on Client\n"; + stats += " on Server on Client\n"; } else { - stats += " on Client on Server\n"; + stats += " on Client on Server\n"; } StringObjAppendPrintf(stats,"Added: %9ld %9ld\n",(long)fLocalItemsAdded,(long)fRemoteItemsAdded); StringObjAppendPrintf(stats,"Deleted: %9ld %9ld\n",(long)fLocalItemsDeleted,(long)fRemoteItemsDeleted); @@ -4555,7 +4555,7 @@ void TLocalEngineDS::showStatistics(void) TSyncOpCommand *TLocalEngineDS::newSyncOpCommand( TSyncItem *aSyncItemP, // the sync item TSyncItemType *aSyncItemTypeP, // the sync item type - cAppCharP aLocalIDPrefix + cAppCharP aLocalIDPrefix ) { // get operation @@ -4568,7 +4568,7 @@ TSyncOpCommand *TLocalEngineDS::newSyncOpCommand( // %%% SCTS does not like SourceURI in Replace and Delete commands sent to Client // there are the only ones allowed to carry a GUID if (IS_SERVER) { - #ifdef SYSYNC_SERVER + #ifdef SYSYNC_SERVER // Server: commands only have remote IDs, except add which only has target ID if (syncop==sop_add || syncop==sop_wants_add) aSyncItemP->clearRemoteID(); // no remote ID @@ -4588,8 +4588,8 @@ TSyncOpCommand *TLocalEngineDS::newSyncOpCommand( if (aSyncItemP->hasLocalID()) { if (IS_SERVER) { #ifdef SYSYNC_SERVER - // make sure GUID (plus prefixes) is not exceeding allowed size - adjustLocalIDforSize(aSyncItemP->fLocalID,getRemoteDatastore()->getMaxGUIDSize(),aLocalIDPrefix ? strlen(aLocalIDPrefix) : 0); + // make sure GUID (plus prefixes) is not exceeding allowed size + adjustLocalIDforSize(aSyncItemP->fLocalID,getRemoteDatastore()->getMaxGUIDSize(),aLocalIDPrefix ? strlen(aLocalIDPrefix) : 0); #endif } // add local ID prefix, if any @@ -4789,7 +4789,7 @@ bool TLocalEngineDS::isAcceptable(TSyncItem *aSyncItemP, TStatusCommand &aStatus if (aSyncItemP->testFilter(fDSConfigP->fRemoteAcceptFilter.c_str())) return true; // ok // not accepted, set 415 error if (!fDSConfigP->fSilentlyDiscardUnaccepted) - aStatusCommand.setStatusCode(415); + aStatusCommand.setStatusCode(415); ADDDEBUGITEM(aStatusCommand,"Received item does not pass acceptance filter"); PDEBUGPRINTFX(DBG_ERROR,( "Received item does not pass acceptance filter: %s", @@ -4862,11 +4862,11 @@ bool TLocalEngineDS::engProcessRemoteItem( { #ifdef SYSYNC_CLIENT if (IS_CLIENT) - return engProcessRemoteItemAsClient(syncitemP,aStatusCommand); // status, must be set to correct status code (ok / error) + return engProcessRemoteItemAsClient(syncitemP,aStatusCommand); // status, must be set to correct status code (ok / error) #endif #ifdef SYSYNC_SERVER if (IS_SERVER) - return engProcessRemoteItemAsServer(syncitemP,aStatusCommand); // status, must be set to correct status code (ok / error) + return engProcessRemoteItemAsServer(syncitemP,aStatusCommand); // status, must be set to correct status code (ok / error) #endif // neither return false; @@ -4916,7 +4916,7 @@ bool TLocalEngineDS::engProcessSyncOpItem( if (!remoteTypeP) { // specified type is not a remote type listed in remote's devInf. // But as remote is actually using it, we can assume it does support it, so use local type of same name instead - PDEBUGPRINTFX(DBG_ERROR,("According to remote devInf, '%s' is not supported, but obviously it is used here so we try to handle it",typestr)); + PDEBUGPRINTFX(DBG_ERROR,("According to remote devInf, '%s' is not supported, but obviously it is used here so we try to handle it",typestr)); // look it up in local datastore's list remoteTypeP=getReceiveType(typestr,NULL); } @@ -5992,8 +5992,8 @@ bool TLocalEngineDS::engProcessRemoteItemAsServer( DB_PROGRESS_EVENT(this,pev_itemprocessed,fLocalItemsAdded,fLocalItemsUpdated,fLocalItemsDeleted); } else { - // if the DB has a error string to show, add it here - aStatusCommand.addItemString(lastDBErrorText().c_str()); + // if the DB has a error string to show, add it here + aStatusCommand.addItemString(lastDBErrorText().c_str()); } // done return ok; @@ -6006,7 +6006,7 @@ void TLocalEngineDS::engRequestEnded(void) { #ifdef SUPERDATASTORES if (fAsSubDatastoreOf) - return; + return; #endif // If DS 1.2: Make sure everything is ready for a resume in case there's an abort (implicit Suspend) // before the next request. Note that the we cannot wait for session timeout, as the resume attempt @@ -6097,8 +6097,8 @@ bool TLocalEngineDS::engProcessRemoteItemAsClient( delete aSyncItemP; return true; } - // let item check itself to catch special cases - // - init variables which are used/modified by item checking + // let item check itself to catch special cases + // - init variables which are used/modified by item checking fItemSizeLimit=-1; // no limit fCurrentSyncOp = syncop; fEchoItemOp = sop_none; @@ -6231,7 +6231,7 @@ bool TLocalEngineDS::engProcessRemoteItemAsClient( } // switch // processed if (ok) { - DB_PROGRESS_EVENT(this,pev_itemprocessed,fLocalItemsAdded,fLocalItemsUpdated,fLocalItemsDeleted); + DB_PROGRESS_EVENT(this,pev_itemprocessed,fLocalItemsAdded,fLocalItemsUpdated,fLocalItemsDeleted); } else { // if the DB has a error string to show, add it here @@ -6587,7 +6587,7 @@ localstatus TLocalEngineDS::engSaveSuspendState(bool aAnyway) if (aAnyway || !isAborted()) { // only save if DS 1.2 and supported by DB if ((fSessionP->getSyncMLVersion()>=syncml_vers_1_2) && dsResumeSupportedInDB()) { - PDEBUGBLOCKFMT(("SaveSuspendState","Saving state for suspend/resume","datastore=%s",getName())); + PDEBUGBLOCKFMT(("SaveSuspendState","Saving state for suspend/resume","datastore=%s",getName())); // save alert state (if not explicitly prevented) fResumeAlertCode=fPreventResuming ? 0 : fAlertCode; if (fResumeAlertCode) { diff --git a/src/sysync/localengineds.h b/src/sysync/localengineds.h index 2ca36d6..9a4d485 100755 --- a/src/sysync/localengineds.h +++ b/src/sysync/localengineds.h @@ -206,9 +206,9 @@ public: // - reset config to defaults virtual void clear(); // - check for alias names - uInt16 isDatastoreAlias(cAppCharP aDatastoreURI); + uInt16 isDatastoreAlias(cAppCharP aDatastoreURI); // - returns true for datastores that are abstract, i.e. don't have a backend implementation (like superdatastores, or non-derived localengineds) - virtual bool isAbstractDatastore(void) { return true; }; // pure localengineds is abstract. First derivate towards backend (stdlogicds) will override this with "false". + virtual bool isAbstractDatastore(void) { return true; }; // pure localengineds is abstract. First derivate towards backend (stdlogicds) will override this with "false". protected: // check config elements #ifndef HARDCODED_CONFIG @@ -315,7 +315,7 @@ protected: /// @{ TLocalEngineDSState fLocalDSState; ///< internal state of the datastore sync process localstatus fAbortStatusCode; ///< status code when engAbortDatastoreSync() was called - bool fLocalAbortCause; ///< flag signalling if abort cause was local or remote + bool fLocalAbortCause; ///< flag signalling if abort cause was local or remote bool fRemoteAddingStopped; ///< set when no more add commands should be sent to remote (e.g. device full) localstatus fAlertCode; ///< alert code in use by this datastore (for scripts and for suspend) /// @} @@ -606,8 +606,8 @@ public: /// datastore options fieldinteger_t getItemSizeLimit(void) { return fItemSizeLimit; }; bool getNoAttachments(void) { - #ifdef SYSYNC_TARGET_OPTIONS - return fNoAttachments; + #ifdef SYSYNC_TARGET_OPTIONS + return fNoAttachments; #else return false; #endif @@ -679,7 +679,7 @@ public: // - make sync set ready SUPERDS_VIRTUAL localstatus engInitForClientSync(void); // - non-superdatastore aware base functionality - localstatus engInitDSForClientSync(void); + localstatus engInitDSForClientSync(void); #endif /// Internal events during sync for derived classes /// @note local DB authorisation must be established already before calling these @@ -918,7 +918,7 @@ public: virtual TSyError TunnelReadItemAsKey(cItemID aID, KeyH aItemKey) { return LOCERR_NOTIMP; }; virtual TSyError TunnelInsertItemAsKey(KeyH aItemKey, ItemID aID) { return LOCERR_NOTIMP; }; virtual TSyError TunnelUpdateItemAsKey(KeyH aItemKey, cItemID aID, ItemID aUpdID) { return LOCERR_NOTIMP; }; - + virtual TSettingsKeyImpl *newTunnelKey(TEngineInterface *) { return NULL; }; /// @} diff --git a/src/sysync/stdlogicds.cpp b/src/sysync/stdlogicds.cpp index c3e4513..242449d 100644 --- a/src/sysync/stdlogicds.cpp +++ b/src/sysync/stdlogicds.cpp @@ -81,7 +81,7 @@ void TStdLogicDS::InternalResetDataStore(void) // no start init request yet fStartInit=false; if(HAS_SERVER_DB) { - #ifdef USES_SERVER_DB + #ifdef USES_SERVER_DB // remove all items TSyncItemPContainer::iterator pos; for (pos=fItems.begin(); pos!=fItems.end(); ++pos) { @@ -91,8 +91,8 @@ void TStdLogicDS::InternalResetDataStore(void) #endif } if (IS_SERVER) { - #ifdef SYSYNC_SERVER - fNumRefOnlyItems=0; + #ifdef SYSYNC_SERVER + fNumRefOnlyItems=0; #endif } } // TStdLogicDS::InternalResetDataStore @@ -155,7 +155,7 @@ localstatus TStdLogicDS::startDataWrite() sta = implStartDataWrite(); fWriteStarted = sta==LOCERR_OK; // must be here to prevent recursion as startDataWrite might be called implicitly below if (HAS_SERVER_DB) { - #ifdef USES_SERVER_DB + #ifdef USES_SERVER_DB // server-type DB needs post-processing to update map entries (client and server case) TSyncItemPContainer::iterator pos; if (sta==LOCERR_OK) { @@ -168,7 +168,7 @@ localstatus TStdLogicDS::startDataWrite() #endif } if (IS_CLIENT && HAS_SERVER_DB) { - #ifdef USES_SERVER_DB + #ifdef USES_SERVER_DB /// @todo we don't need the items to remain that long at all - not even for CLIENT_USES_SERVER_DB case fItems.clear(); // empty list #endif @@ -215,7 +215,7 @@ bool TStdLogicDS::logicRetrieveItemByID( /// or cannot be reached within the maximally allowed request processing time left. bool TStdLogicDS::isStarted(bool aWait) { - #ifdef SYSYNC_SERVER + #ifdef SYSYNC_SERVER if (IS_SERVER) { // only server has threaded datastores so far if (aWait && fInitializing) { @@ -257,7 +257,7 @@ void TStdLogicDS::logicMarkItemForResend(cAppCharP aLocalID, cAppCharP aRemoteID localstatus TStdLogicDS::logicSaveResumeMarks(void) { PDEBUGBLOCKFMTCOLL(("SaveResumeMarks","let implementation save resume info","datastore=%s",getName())); - localstatus sta = implSaveResumeMarks(); + localstatus sta = implSaveResumeMarks(); PDEBUGENDBLOCK("SaveResumeMarks"); return sta; } // TStdLogicDS::logicSaveResumeMarks @@ -270,7 +270,7 @@ localstatus TStdLogicDS::logicSaveResumeMarks(void) // Must return -1 if no NOC value can be returned sInt32 TStdLogicDS::getNumberOfChanges(void) { - if (IS_SERVER) { + if (IS_SERVER) { #ifdef SYSYNC_SERVER // for server, number of changes is the number of items in the item list // minus those that are for reference only (in a slow sync resume) @@ -278,10 +278,10 @@ sInt32 TStdLogicDS::getNumberOfChanges(void) #endif } else { - // for client, derived class must provide it, or we'll return the default here (=no NOC) + // for client, derived class must provide it, or we'll return the default here (=no NOC) // Note: for client-only builds, this methods does not exist in StdLogicDS and thus // inherited is always used - return inherited::getNumberOfChanges(); + return inherited::getNumberOfChanges(); } } // TStdLogicDS::getNumberOfChanges @@ -357,7 +357,7 @@ localstatus TStdLogicDS::performStartSync(void) myitemP->cleardata(); // also get rid of unneeded data } else - sop=sop_none; // ignore all others (especially adds or slowsync replaces) + sop=sop_none; // ignore all others (especially adds or slowsync replaces) } else { // item passes = belongs to sync set @@ -530,7 +530,7 @@ localstatus TStdLogicDS::startDataAccessForServer(void) ); // - datastoreinitscript might abort the sync with this datastore, check for that and exit if so if (isAborted()) { - return getAbortStatusCode(); + return getAbortStatusCode(); } #endif // - init post fetch filtering, sets fFilteringNeededForAll and fFilteringNeeded correctly @@ -957,7 +957,7 @@ bool TStdLogicDS::logicGenerateSyncCommandsAsClient( // get sync op to perform TSyncOperation syncop=syncitemP->getSyncOp(); if (syncop!=sop_delete && syncop!=sop_soft_delete && syncop!=sop_archive_delete) { - #ifdef OBJECT_FILTERING + #ifdef OBJECT_FILTERING // Filtering // - call this anyway (makes sure item is made conformant to remoteAccept filter, even if // fFilteringNeeded is not set) @@ -968,7 +968,7 @@ bool TStdLogicDS::logicGenerateSyncCommandsAsClient( // later should they match the filter criteria again), we can implement removing based // on filter criteria. Otherwise, these are simply ignored. if (implTracksSyncopChanges() && !fSlowSync && changed && (syncop==sop_replace || syncop==sop_wants_replace)) { - // item already exists on remote but falls out of syncset now: delete + // item already exists on remote but falls out of syncset now: delete // NOTE: This works only if reviewReadItem() is correctly implemented // and checks for items that are deleted after being reported // as replace to delete their local map entry (which makes @@ -977,12 +977,12 @@ bool TStdLogicDS::logicGenerateSyncCommandsAsClient( syncitemP->cleardata(); // also get rid of unneeded data } else - syncop = sop_none; // ignore all others (especially adds or slowsync replaces) + syncop = sop_none; // ignore all others (especially adds or slowsync replaces) } else #endif { - // item passes (or no filters anyway) -> belongs to sync set + // item passes (or no filters anyway) -> belongs to sync set if ((syncop==sop_replace || syncop==sop_wants_replace) && !changed && !fSlowSync) { // exists but has not changed since last sync syncop=sop_none; // ignore for now @@ -1051,8 +1051,8 @@ bool TStdLogicDS::logicGenerateSyncCommandsAsClient( /// @brief called to have all not-yet-generated sync commands as "to-be-resumed" void TStdLogicDS::logicMarkOnlyUngeneratedForResume(void) { - if (IS_SERVER) { - #ifdef SYSYNC_SERVER + if (IS_SERVER) { + #ifdef SYSYNC_SERVER // we do not maintain the map/bookmark list at this level, so // derived class (ODBC, BinFile etc.) must make sure that their list is // clean (no marks from previous sessions) before calling this inherited version @@ -1068,7 +1068,7 @@ void TStdLogicDS::logicMarkOnlyUngeneratedForResume(void) #endif // SYSYNC_SERVER } else { - #ifdef SYSYNC_CLIENT + #ifdef SYSYNC_CLIENT // we do not maintain the map/bookmark list at this level, so // derived class (ODBC, BinFile etc.) must make sure that their list is // clean (no marks from previous sessions) before calling this inherited version @@ -1102,7 +1102,7 @@ bool TStdLogicDS::logicProcessRemoteItem( // start writing if not already started sta=startDataWrite(); if (sta!=LOCERR_OK) { - aStatusCommand.setStatusCode(sta); + aStatusCommand.setStatusCode(sta); } else { // show @@ -1238,7 +1238,7 @@ bool TStdLogicDS::logicProcessRemoteItem( syncitemP->setSyncOp(sop_add); PDEBUGPRINTFX(DBG_DATA,("TStdLogicDS: RetrieveItem: not found (Status=%hd) --> adding instead",sta)); if (IS_SERVER) { - #ifdef SYSYNC_SERVER + #ifdef SYSYNC_SERVER // server: make sure we delete the old item from the map table (as we *know* the item is gone - should it reappear under a different localID, it'll be re-added) implProcessMap(syncitemP->getRemoteID(),NULL); #endif @@ -1287,9 +1287,9 @@ bool TStdLogicDS::logicProcessRemoteItem( if (sta==418) { // 418: item already exists, this is kind of a conflict if (isResuming() || fIgnoreUpdate || IS_CLIENT) { - // - in a client, this should not happen (prevented via checking against pending maps before + // - in a client, this should not happen (prevented via checking against pending maps before // this routine is called) - if it still does just report the status back - // - in a resume, this can happen and the add should be ignored (se we return the status 418) + // - in a resume, this can happen and the add should be ignored (se we return the status 418) // - if updates are to be ignored, don't try update instead (and report 418) // --> just return the status as-is } @@ -1328,7 +1328,7 @@ bool TStdLogicDS::logicProcessRemoteItem( // - switch to add if remote sent remoteID along so we can properly map syncitemP->setSyncOp(sop_add); if (IS_SERVER) { - #ifdef SYSYNC_SERVER + #ifdef SYSYNC_SERVER // - make sure we delete the old item from the map table (as we *know* the item is gone - should it reappear under a different localID, it'll be re-added) implProcessMap(syncitemP->getRemoteID(),NULL); #endif @@ -1336,7 +1336,7 @@ bool TStdLogicDS::logicProcessRemoteItem( else { // we can handle it, as we know the remoteID irregular=true; - } + } PDEBUGPRINTFX(DBG_DATA,("to-be-replaced item not found (Status=%hd) --> adding instead",sta)); // - process again (note that we are re-using the status command that might // already have a text item with an OS errir if something failed before) @@ -1424,13 +1424,13 @@ localstatus TStdLogicDS::dsBeforeStateChange(TLocalEngineDSState aOldState,TLoca if (aNewState==dssta_dataaccessstarted) { // start data access if (IS_CLIENT) { - #ifdef SYSYNC_CLIENT - sta = startDataAccessForClient(); + #ifdef SYSYNC_CLIENT + sta = startDataAccessForClient(); #endif } else { #ifdef SYSYNC_SERVER - sta = startDataAccessForServer(); + sta = startDataAccessForServer(); #endif } } diff --git a/src/sysync/stdlogicds.h b/src/sysync/stdlogicds.h index 19cc2be..b54201c 100755 --- a/src/sysync/stdlogicds.h +++ b/src/sysync/stdlogicds.h @@ -28,13 +28,13 @@ #endif #if defined(CLIENT_USES_SERVER_DB) - #define USES_SERVER_DB 1 - #define HAS_SERVER_DB 1 + #define USES_SERVER_DB 1 + #define HAS_SERVER_DB 1 #else - #ifdef SERVER_SUPPORT - #define USES_SERVER_DB 1 + #ifdef SERVER_SUPPORT + #define USES_SERVER_DB 1 #endif - #define HAS_SERVER_DB IS_SERVER + #define HAS_SERVER_DB IS_SERVER #endif using namespace sysync; @@ -228,15 +228,15 @@ protected: virtual localstatus implStartDataWrite(void) = 0; /// Returns true when DB can track syncop changes (i.e. having the DB report /// items as added again when stdlogic filters have decided they fell out of the syncset, - /// and has announced this to the DB using implReviewReadItem(). - virtual bool implTracksSyncopChanges(void) { return false; }; // derived DB class needs to confirm true if - /// review reported entry (allows post-processing such as map deleting) - /// MUST be called after implStartDataWrite, before any actual writing, - /// for each item obtained in implGetItem - virtual localstatus implReviewReadItem( - TSyncItem &aItem ///< the item - ) = 0; - #ifdef SYSYNC_SERVER + /// and has announced this to the DB using implReviewReadItem(). + virtual bool implTracksSyncopChanges(void) { return false; }; // derived DB class needs to confirm true if + /// review reported entry (allows post-processing such as map deleting) + /// MUST be called after implStartDataWrite, before any actual writing, + /// for each item obtained in implGetItem + virtual localstatus implReviewReadItem( + TSyncItem &aItem ///< the item + ) = 0; + #ifdef SYSYNC_SERVER /// called to set maps. /// @note aLocalID or aRemoteID can be NULL - which signifies deletion of a map entry /// @note that this might be needed for clients accessing a server-style database as well @@ -296,23 +296,23 @@ private: virtual bool logicGenerateSyncCommandsAsServer( TSmlCommandPContainer &aNextMessageCommands, TSmlCommand * &aInterruptedCommandP, - cAppCharP aLocalIDPrefix + cAppCharP aLocalIDPrefix ); /// called for servers when receiving map from client /// @note aLocalID or aRemoteID can be NULL - which signifies deletion of a map entry virtual localstatus logicProcessMap(cAppCharP aLocalID, cAppCharP aRemoteID); #endif // SYSYNC_SERVER - + #ifdef SYSYNC_CLIENT /// called to generate sync sub-commands as server for remote client /// @return true if now finished for this datastore virtual bool logicGenerateSyncCommandsAsClient( TSmlCommandPContainer &aNextMessageCommands, TSmlCommand * &aInterruptedCommandP, - cAppCharP aLocalIDPrefix + cAppCharP aLocalIDPrefix ); #endif // SYSYNC_CLIENT - + // - determine if this is a first time sync situation virtual bool isFirstTimeSync(void) { return fFirstTimeSync; }; @@ -366,6 +366,6 @@ private: } // namespace sysync -#endif // TStdLogicDS_H +#endif // TStdLogicDS_H // eof |