syncmapping.cpp
00001 /* 00002 This file is part of libqopensync. 00003 00004 Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #include <tqstring.h> 00023 #include <osengine/engine.h> 00024 00025 #include "syncmapping.h" 00026 00027 using namespace QSync; 00028 00029 SyncMapping::SyncMapping() 00030 : mEngine( 0 ), mMapping( 0 ) 00031 { 00032 } 00033 00034 SyncMapping::SyncMapping( OSyncMapping *mapping, OSyncEngine *engine ) 00035 : mEngine( engine ), mMapping( mapping ) 00036 { 00037 } 00038 00039 SyncMapping::~SyncMapping() 00040 { 00041 } 00042 00043 bool SyncMapping::isValid() const 00044 { 00045 return ( mEngine != 0 && mMapping != 0 ); 00046 } 00047 00048 long long SyncMapping::id() const 00049 { 00050 Q_ASSERT( mMapping ); 00051 00052 return osengine_mapping_get_id( mMapping ); 00053 } 00054 00055 void SyncMapping::duplicate() 00056 { 00057 Q_ASSERT( mEngine ); 00058 Q_ASSERT( mMapping ); 00059 00060 osengine_mapping_duplicate( mEngine, mMapping ); 00061 } 00062 00063 void SyncMapping::solve( const SyncChange &change ) 00064 { 00065 Q_ASSERT( mEngine ); 00066 Q_ASSERT( mMapping ); 00067 Q_ASSERT( change.isValid() ); 00068 00069 osengine_mapping_solve( mEngine, mMapping, change.mSyncChange ); 00070 } 00071 00072 void SyncMapping::ignore() 00073 { 00074 Q_ASSERT( mEngine ); 00075 Q_ASSERT( mMapping ); 00076 00077 //TODO: error should be returned as Result 00078 OSyncError *error = 0; 00079 osengine_mapping_ignore_conflict( mEngine, mMapping, &error ); 00080 } 00081 00082 int SyncMapping::changesCount() const 00083 { 00084 Q_ASSERT( mMapping ); 00085 00086 return osengine_mapping_num_changes( mMapping ); 00087 } 00088 00089 SyncChange SyncMapping::changeAt( int pos ) 00090 { 00091 Q_ASSERT( mMapping ); 00092 00093 if ( pos < 0 || pos >= osengine_mapping_num_changes( mMapping ) ) 00094 return SyncChange(); 00095 00096 OSyncChange *ochange = osengine_mapping_nth_change( mMapping, pos ); 00097 00098 return SyncChange( ochange ); 00099 } 00100