standardsync.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "standardsync.h"
00023
00024 #include "syncer.h"
00025 #include "syncee.h"
00026
00027 #include <kdebug.h>
00028
00029 using namespace KSync;
00030
00031 void StandardSync::syncToTarget( Syncee *source, Syncee *target, bool override )
00032 {
00033 kdDebug(5250) << "StandardSync::syncToTarget(): from: "
00034 << source->identifier()
00035 << " to: " << target->identifier() << " override: "
00036 << override << endl;
00037
00038 SyncEntry *sourceEntry;
00039 for( sourceEntry = source->firstEntry(); sourceEntry;
00040 sourceEntry = source->nextEntry() ) {
00041 kdDebug(5250) << "SYNC: sourceEntry: " << sourceEntry->id()
00042 << " (" << sourceEntry->name() << ")"
00043 << " " << long( sourceEntry ) << endl;
00044 if ( sourceEntry->dontSync() ) {
00045 kdDebug(5250) << "SYNC: source don't sync" << endl;
00046 continue;
00047 }
00048 SyncEntry *targetEntry = target->findEntry( sourceEntry->id() );
00049 if ( targetEntry ) {
00050 kdDebug(5250) << "SYNC: targetEntry: " << targetEntry->id()
00051 << " (" << targetEntry->name() << ")"
00052 << " " << long( targetEntry ) << endl;
00053 if ( targetEntry->dontSync() ) {
00054 kdDebug(5250) << "SYNC: target don't sync" << endl;
00055 continue;
00056 }
00057 kdDebug(5250) << "SYNC: entry exists" << endl;
00058
00059 if ( sourceEntry->equals( targetEntry ) ) {
00060
00061 kdDebug(5250) << "SYNC: equal" << endl;
00062 } else {
00063 kdDebug(5250) << "SYNC: entries are different" << endl;
00064
00065 if ( override ) {
00066
00067 target->replaceEntry( targetEntry, sourceEntry );
00068 kdDebug(5250) << "SYNC: force replace" << endl;
00069 } else {
00070 if ( source->hasChanged( sourceEntry ) &&
00071 target->hasChanged( targetEntry ) ) {
00072
00073 kdDebug(5250) << "SYNC: Both have changed" << endl;
00074 SyncEntry *result = deconflict( sourceEntry, targetEntry );
00075 if ( !result ) {
00076 kdDebug(5250) << "SYNC: no decision" << endl;
00077 sourceEntry->setDontSync( true );
00078 targetEntry->setDontSync( true );
00079 } else {
00080 if ( result == sourceEntry ) {
00081 kdDebug(5250) << "SYNC: take source" << endl;
00082 target->replaceEntry( targetEntry, sourceEntry );
00083 } else {
00084 kdDebug(5250) << "SYNC: take target" << endl;
00085 }
00086 }
00087 } else if ( source->hasChanged( sourceEntry ) &&
00088 !target->hasChanged( targetEntry ) ) {
00089
00090 target->replaceEntry( targetEntry, sourceEntry );
00091 kdDebug(5250) << "SYNC: source changed, target not" << endl;
00092 kdDebug(5250) << "SYNC: Take source entry." << endl;
00093 } else if ( !source->hasChanged( sourceEntry ) &&
00094 target->hasChanged( targetEntry ) ) {
00095
00096 kdDebug(5250) << "SYNC: target changed, source not" << endl;
00097 kdDebug(5250) << "SYNC: Take target entry." << endl;
00098 } else {
00099 kdDebug(5250) << "SYNC: nothing has changed." << endl;
00100 }
00101 }
00102 }
00103 } else {
00104
00105 target->addEntry( sourceEntry );
00106 kdDebug(5250) << "SYNC: New entry." << endl;
00107 }
00108 }
00109 }
This file is part of the documentation for kitchensync Library Version 3.3.2.