itemsync.h
00001 /* 00002 Copyright (c) 2007 Tobias Koenig <tokoe@kde.org> 00003 00004 This library is free software; you can redistribute it and/or modify it 00005 under the terms of the GNU Library General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or (at your 00007 option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to the 00016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301, USA. 00018 */ 00019 00020 #ifndef AKONADI_ITEMSYNC_H 00021 #define AKONADI_ITEMSYNC_H 00022 00023 #include "akonadi_export.h" 00024 00025 #include <akonadi/item.h> 00026 #include <akonadi/job.h> 00027 00028 namespace Akonadi { 00029 00030 class Collection; 00031 class ItemFetchScope; 00032 00053 class AKONADI_EXPORT ItemSync : public Job 00054 { 00055 Q_OBJECT 00056 00057 public: 00064 explicit ItemSync( const Collection &collection, QObject *parent = 0 ); 00065 00069 ~ItemSync(); 00070 00081 void setFullSyncItems( const Item::List &items ); 00082 00089 void setTotalItems( int amount ); 00090 00097 void setStreamingEnabled( bool enable ); 00098 00103 void deliveryDone(); 00104 00116 void setIncrementalSyncItems( const Item::List &changedItems, 00117 const Item::List &removedItems ); 00118 00130 void setFetchScope( ItemFetchScope &fetchScope ); 00131 00144 ItemFetchScope &fetchScope(); 00145 00152 void rollback(); 00153 00158 enum TransactionMode { 00159 SingleTransaction, 00160 MultipleTransactions, 00161 NoTransaction 00162 }; 00163 00169 void setTransactionMode( TransactionMode mode ); 00170 00171 protected: 00172 void doStart(); 00173 void slotResult( KJob* job ); 00174 00181 virtual bool updateItem( const Item &storedItem, Item &newItem ); 00182 00183 private: 00184 //@cond PRIVATE 00185 class Private; 00186 Private* const d; 00187 00188 Q_PRIVATE_SLOT( d, void slotLocalListDone( KJob* ) ) 00189 Q_PRIVATE_SLOT( d, void slotLocalDeleteDone( KJob* ) ) 00190 Q_PRIVATE_SLOT( d, void slotLocalChangeDone( KJob* ) ) 00191 Q_PRIVATE_SLOT( d, void slotTransactionResult( KJob* ) ) 00192 //@endcond 00193 }; 00194 00195 } 00196 00197 #endif