~ubuntu-branches/ubuntu/karmic/kdepim/karmic-backports

« back to all changes in this revision

Viewing changes to akonadi/opensync/datasink.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi, Alessandro Ghersi, Harald Sitter
  • Date: 2009-06-27 04:40:05 UTC
  • mfrom: (1.1.39 upstream)
  • Revision ID: james.westby@ubuntu.com-20090627044005-4y2vm9xz7rvmzi4p
Tags: 4:4.2.95svn20090701-0ubuntu1
[ Alessandro Ghersi ]
* New upstream release
  - Bump build-deps
* Remove akonadi-kde and libmaildir4 packages
  - remove akonadi-kde.install and libmaildir4.install
  - remove libmaildir4 from debian/rules
  - remove akonadi-kde and libmaildir4 from depends
  - remove akonadi-kde and libmaildir4 from installgen
* Update kdepim-dev.install
* Update kpilot.install
* Add akonadi-kde and libmaildir4 transitional packages

[ Harald Sitter ]
* KAddressbook replaces Kontact << 4.2.85 (LP: #378373)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2008 Volker Krause <vkrause@kde.org>
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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.
 
18
*/
 
19
 
 
20
#ifndef DATASINK_H
 
21
#define DATASINK_H
 
22
 
 
23
#include "sinkbase.h"
 
24
 
 
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>
 
30
 
 
31
#include <opensync/opensync.h>
 
32
#include <opensync/opensync-plugin.h>
 
33
#include <opensync/opensync-data.h>
 
34
#include <opensync/opensync-format.h>
 
35
 
 
36
#include <boost/shared_ptr.hpp>
 
37
 
 
38
using namespace Akonadi;
 
39
 
 
40
/**
 
41
 * Base class for data sink classes, dealing with the type-independent stuff.
 
42
 */
 
43
class DataSink : public SinkBase
 
44
{
 
45
  Q_OBJECT
 
46
 
 
47
  public:
 
48
    enum Type { Calendar = 0, Contacts, Notes };
 
49
 
 
50
    DataSink( int type );
 
51
    ~DataSink();
 
52
 
 
53
    bool initialize( OSyncPlugin *plugin, OSyncPluginInfo *info, OSyncObjTypeSink *sink, OSyncError **error );
 
54
 
 
55
    void getChanges();
 
56
    void commit( OSyncChange *change );
 
57
    void syncDone();
 
58
 
 
59
  public slots:
 
60
    void slotGetChangesFinished( KJob * );
 
61
    void slotItemsReceived( const Akonadi::Item::List & );
 
62
 
 
63
  protected:
 
64
    /**
 
65
     * Returns the collection we are supposed to sync with.
 
66
     */
 
67
    Akonadi::Collection collection() const;
 
68
 
 
69
    /**
 
70
     * This reports the change back to opensync
 
71
    */
 
72
    void reportChange( const Item& item, const QString& format );
 
73
 
 
74
    /**
 
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.
 
76
     */
 
77
    void reportChange( const Item & item );
 
78
 
 
79
    /**
 
80
     * Creates a new item based on the data given by opensync.
 
81
     */
 
82
    const Item createItem( OSyncChange *change );
 
83
    /**
 
84
     * Modified an item based on the data given by opensync.
 
85
     */
 
86
    const Item modifyItem( OSyncChange *change );
 
87
    /**
 
88
     * Deletes an item based on the data given by opensync.
 
89
     */
 
90
    void deleteItem( OSyncChange *change );
 
91
 
 
92
  private:
 
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 );
 
97
 
 
98
  private:
 
99
    OSyncHashTable *m_hashtable;
 
100
    int m_type;
 
101
};
 
102
 
 
103
#endif