2
Copyright (c) 2008 Volker Krause <vkrause@kde.org>
4
This library is free software; you can redistribute it and/or modify it
5
under the terms of the GNU Library General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or (at your
7
option) any later version.
9
This library is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12
License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to the
16
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25
#include <akonadi/collection.h>
26
#include <akonadi/itemfetchjob.h>
27
#include <akonadi/itemcreatejob.h>
28
#include <akonadi/itemmodifyjob.h>
29
#include <akonadi/itemfetchscope.h>
31
#include <opensync/opensync.h>
32
#include <opensync/opensync-plugin.h>
33
#include <opensync/opensync-data.h>
34
#include <opensync/opensync-format.h>
36
#include <boost/shared_ptr.hpp>
38
using namespace Akonadi;
41
* Base class for data sink classes, dealing with the type-independent stuff.
43
class DataSink : public SinkBase
48
enum Type { Calendar = 0, Contacts, Notes };
53
bool initialize( OSyncPlugin *plugin, OSyncPluginInfo *info, OSyncObjTypeSink *sink, OSyncError **error );
56
void commit( OSyncChange *change );
60
void slotGetChangesFinished( KJob * );
61
void slotItemsReceived( const Akonadi::Item::List & );
65
* Returns the collection we are supposed to sync with.
67
Akonadi::Collection collection() const;
70
* This reports the change back to opensync
72
void reportChange( const Item& item, const QString& format );
75
* Reimplement in subclass to provide data about changes to opensync. Note, that you must call DataSink::reportChange( Item, QString, int ) after you have organized data to be send to opensync.
77
void reportChange( const Item & item );
80
* Creates a new item based on the data given by opensync.
82
const Item createItem( OSyncChange *change );
84
* Modified an item based on the data given by opensync.
86
const Item modifyItem( OSyncChange *change );
88
* Deletes an item based on the data given by opensync.
90
void deleteItem( OSyncChange *change );
93
const Item createAkonadiItem( OSyncChange *change );
94
const Item fetchItem( const QString& id );
95
const QString formatName();
96
bool setPayload( Item *item, const QString &str );
99
OSyncHashTable *m_hashtable;