- forgot to remove some testing code
[opensync/akonadi-sync-cdf.git] / src / sinkbase.h
blobcd5ef584d554c6b179b8c6f38dc9fd1723522c87
1 /*
2 Copyright (c) 2008 Volker Krause <vkrause@kde.org>
3 Copyright (c) 2010 Emanoil Kotsev <deloptes@yahoo.com>
5 $Id$
7 This library is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Library General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or (at your
10 option) any later version.
12 This library is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15 License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to the
19 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301, USA.
23 #ifndef SINKBASE_H
24 #define SINKBASE_H
26 #include <QObject>
28 #include <opensync/opensync.h>
29 #include <opensync/opensync-plugin.h>
30 #include <opensync/opensync-helper.h>
32 /**
33 * Base class providing wraping of OSyncObjTypeSink.
35 class SinkBase : public QObject
37 Q_OBJECT
39 public:
40 enum Feature {
41 Connect = 1,
42 Disconnect = 2,
43 GetChanges = 4,
44 Commit = 8,
45 Write = 16,
46 CommittedAll = 32,
47 Read = 64,
48 BatchCommit = 128,
49 SyncDone = 256
52 SinkBase( int features );
53 virtual ~SinkBase();
55 virtual void connect();
56 virtual void disconnect();
57 virtual void getChanges();
58 virtual void commit( OSyncChange *chg );
59 // virtual void write();
60 // virtual void read();
61 // virtual void commitAll();
62 virtual void syncDone();
64 OSyncContext* context() const {
65 return mContext;
68 OSyncPluginInfo *pluginInfo() const {
69 return mPluginInfo;
71 osync_bool getSlowSink ();
73 void setPluginInfo( OSyncPluginInfo *info );
74 void setContext( OSyncContext *context );
75 void setSink( OSyncObjTypeSink *sink);
76 void setSlowSink (osync_bool);
78 protected:
79 void success() const;
80 void error(OSyncErrorType type, QString msg) const;
81 void warning( OSyncError *error ) const;
82 void wrapSink(OSyncObjTypeSink* sink );
83 OSyncObjTypeSink* sink() const {
84 return mSink;
87 private:
89 OSyncObjTypeSink *mSink;
90 OSyncPluginInfo *mPluginInfo;
91 mutable OSyncContext *mContext;
92 // what do we have and what can we do
93 bool m_canConnect, m_canDisconnect, m_canCommit, m_canCommitAll,
94 m_canGetChanges, m_canWrite, m_canRead, m_canSyncDone;
95 // unused bool m_canCommitRead, m_canBatchCommit;
96 osync_bool m_SlowSync;
99 #endif //End of SINKBASE_H