~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/generic/dataengines/akonadi/akonadiengine.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2007 Volker Krause <vkrause@kde.org>
 
3
    Copyright (c) 2009 Sebastian Kügler <sebas@kde.org>
 
4
 
 
5
    This library is free software; you can redistribute it and/or modify it
 
6
    under the terms of the GNU Library General Public License as published by
 
7
    the Free Software Foundation; either version 2 of the License, or (at your
 
8
    option) any later version.
 
9
 
 
10
    This library is distributed in the hope that it will be useful, but WITHOUT
 
11
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
12
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
 
13
    License for more details.
 
14
 
 
15
    You should have received a copy of the GNU Library General Public License
 
16
    along with this library; see the file COPYING.LIB.  If not, write to the
 
17
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
18
    02110-1301, USA.
 
19
*/
 
20
 
 
21
 
 
22
#ifndef AKONADIENGINE_H
 
23
#define AKONADIENGINE_H
 
24
 
 
25
#include <plasma/dataengine.h>
 
26
 
 
27
#include <Akonadi/Item>
 
28
#include <Akonadi/Monitor>
 
29
 
 
30
#include <kmime/kmime_message.h>
 
31
#include <kabc/addressee.h>
 
32
 
 
33
#include <boost/shared_ptr.hpp>
 
34
typedef boost::shared_ptr<KMime::Message> MessagePtr;
 
35
 
 
36
class KJob;
 
37
 
 
38
class AkonadiEngine : public Plasma::DataEngine
 
39
{
 
40
    Q_OBJECT
 
41
 
 
42
    public:
 
43
        AkonadiEngine( QObject* parent, const QVariantList& args );
 
44
        ~AkonadiEngine();
 
45
        QStringList sources() const;
 
46
 
 
47
    protected:
 
48
        bool sourceRequestEvent(const QString &name);
 
49
 
 
50
    private slots:
 
51
 
 
52
        void stopMonitor(const QString &name);
 
53
 
 
54
        void fetchEmailCollectionDone(KJob* job); // done retrieving whole collection
 
55
        void fetchContactCollectionDone(KJob* job); // done retrieving a whole contact collection
 
56
        void fetchMicroBlogDone(KJob* job);
 
57
 
 
58
        void emailItemsReceived(const Akonadi::Item::List &items);
 
59
 
 
60
        void fetchEmailCollectionsDone(KJob* job); // got list of collections
 
61
        void fetchContactCollectionsDone(KJob* job);
 
62
        void fetchMicroBlogCollectionsDone(KJob* job);
 
63
 
 
64
        void emailItemAdded(const Akonadi::Item &item, const QString &collection = QString());
 
65
        void contactItemAdded(const Akonadi::Item & item);
 
66
        void microBlogItemAdded(const Akonadi::Item &item);
 
67
 
 
68
    private:
 
69
        void initEmailMonitor();
 
70
        void initContactMonitor();
 
71
        void initMicroBlogMonitor();
 
72
        // useful for debugging
 
73
        void printMessage(MessagePtr msg);
 
74
        void printContact(const QString &source, const KABC::Addressee &a);
 
75
 
 
76
        Akonadi::Monitor* m_emailMonitor;
 
77
        Akonadi::Monitor* m_contactMonitor;
 
78
        Akonadi::Monitor* m_microBlogMonitor;
 
79
 
 
80
        QHash<KJob*, QString> m_jobCollections;
 
81
};
 
82
 
 
83
K_EXPORT_PLASMA_DATAENGINE(akonadi, AkonadiEngine)
 
84
 
 
85
#endif