kitchensync
syncentry.cpp
00001 /* 00002 This file is part of KitchenSync. 00003 00004 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 00005 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #include "syncentry.h" 00024 00025 #include "merger.h" 00026 #include "syncee.h" 00027 00028 #include <kdebug.h> 00029 00030 00031 using namespace KSync; 00032 00033 SyncEntry::SyncEntry( Syncee *sync ) 00034 : mSyncee( sync ), mDontSync( false ) 00035 { 00036 mState = Undefined; 00037 } 00038 00039 SyncEntry::SyncEntry( const SyncEntry &ent ) 00040 { 00041 mState = ent.mState; 00042 mSyncee = ent.mSyncee; 00043 mDontSync = ent.mDontSync; 00044 mType = ent.mType; 00045 } 00046 00047 SyncEntry::~SyncEntry() 00048 { 00049 } 00050 00051 void SyncEntry::setSyncee( Syncee *syncee ) 00052 { 00053 mSyncee = syncee; 00054 } 00055 00056 int SyncEntry::match( SyncEntry* /*entry*/ ) 00057 { 00058 return -2; 00059 } 00060 00061 int SyncEntry::compareTo(SyncEntry* /*entry*/ ) 00062 { 00063 return -2; 00064 } 00065 00066 int SyncEntry::state() const 00067 { 00068 return mState; 00069 } 00070 00071 bool SyncEntry::wasAdded() const 00072 { 00073 return ( mState == Added ); 00074 } 00075 00076 bool SyncEntry::wasModified() const 00077 { 00078 return ( mState == Modified ); 00079 } 00080 00081 bool SyncEntry::wasRemoved() const 00082 { 00083 return ( mState == Removed ); 00084 } 00085 00086 void SyncEntry::setState( int state ) 00087 { 00088 mState = state; 00089 } 00090 00091 void SyncEntry::setSyncState( int state ) 00092 { 00093 mSyncState = state; 00094 } 00095 00096 int SyncEntry::syncState() const 00097 { 00098 return mSyncState; 00099 } 00100 00101 Syncee *SyncEntry::syncee()const 00102 { 00103 return mSyncee; 00104 } 00105 00106 void SyncEntry::setDontSync( bool dontSync ) 00107 { 00108 mDontSync = dontSync; 00109 } 00110 00111 bool SyncEntry::dontSync() const 00112 { 00113 return mDontSync; 00114 } 00115 00116 KSync::Merger* SyncEntry::merger()const { 00117 if ( !syncee() ) 00118 return 0l; 00119 00120 return syncee()->merger(); 00121 } 00122 00123 bool SyncEntry::mergeWith( SyncEntry* other ) { 00124 if ( !merger() && !other->merger() ) 00125 return false; 00126 00127 /* try at least one merger */ 00128 Merger *mer = merger() ? merger() : other->merger(); 00129 00130 return mer ->merge( this, other ); 00131 } 00132 00133 KPIM::DiffAlgo* SyncEntry::diffAlgo( SyncEntry*, SyncEntry* ) 00134 { 00135 return 0; 00136 } 00137 00138 /* not implemented here */ 00139 void SyncEntry::setId( const QString& ) 00140 { 00141 } 00142 00143 QString SyncEntry::type()const 00144 { 00145 return mType; 00146 } 00147 00148 void SyncEntry::setType( const QString& str ) 00149 { 00150 mType = str; 00151 }