Still need the exceptions flag....
[opensync/akonadi-sync-cdf.git] / src / akonadisink.cpp
blobb8a15bebc13ef8acd53783cbd54d3ff4bc48ca76
1 /*
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
17 02110-1301, USA.
20 #include "akonadisink.h"
22 #include <akonadi/control.h>
24 #include <KDebug>
26 AkonadiSink::AkonadiSink() :
27 SinkBase( Connect )
31 AkonadiSink::~AkonadiSink()
35 bool AkonadiSink::initialize(OSyncPlugin * plugin, OSyncPluginInfo * info, OSyncError ** error)
37 Q_UNUSED(plugin)
38 kDebug();
39 OSyncObjTypeSink *sink = osync_objtype_main_sink_new( error );
40 wrapSink( sink );
41 // osync_objtype_sink_set_userdata ( sink, this );
42 osync_plugin_info_set_main_sink( info, sink );
43 osync_objtype_sink_unref(sink);
44 return true;
47 void AkonadiSink::connect()
49 osync_trace(TRACE_ENTRY, "%s(%p, %p)", __PRETTY_FUNCTION__, pluginInfo(), context());
50 kDebug();
52 if ( !Akonadi::Control::start() ) {
53 kDebug() << "Could not start Akonadi." ;
54 error( OSYNC_ERROR_NO_CONNECTION, "Could not start Akonadi." );
55 osync_trace(TRACE_EXIT_ERROR, "%s: %s", __PRETTY_FUNCTION__, "Could not start Akonadi.");
56 return;
59 success();
60 osync_trace(TRACE_EXIT, "%s", __PRETTY_FUNCTION__);
63 #include "akonadisink.moc"