~phablet-team/address-book-service/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
 * Copyright 2013 Canonical Ltd.
 *
 * This file is part of contact-service-app.
 *
 * contact-service-app is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 3.
 *
 * contact-service-app is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __GALERA_VIEW_ADAPTOR_H__
#define __GALERA_VIEW_ADAPTOR_H__

#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtCore/QStringList>

#include <QtDBus/QtDBus>

#include "common/dbus-service-defs.h"

namespace galera
{

class View;
class ViewAdaptor: public QDBusAbstractAdaptor
{
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", CPIM_ADDRESSBOOK_VIEW_IFACE_NAME)
    Q_CLASSINFO("D-Bus Introspection", ""
"  <interface name=\"com.canonical.pim.AddressBookView\">\n"
"    <property name=\"count\" type=\"i\" access=\"read\"/>\n"
"    <signal name=\"contactsUpdated\">\n"
"      <arg direction=\"out\" type=\"i\" name=\"pos\"/>\n"
"      <arg direction=\"out\" type=\"i\" name=\"length\"/>\n"
"    </signal>\n"
"    <signal name=\"contactsRemoved\">\n"
"      <arg direction=\"out\" type=\"i\" name=\"pos\"/>\n"
"      <arg direction=\"out\" type=\"i\" name=\"length\"/>\n"
"    </signal>\n"
"    <signal name=\"contactsAdded\">\n"
"      <arg direction=\"out\" type=\"i\" name=\"pos\"/>\n"
"      <arg direction=\"out\" type=\"i\" name=\"length\"/>\n"
"    </signal>\n"
"    <method name=\"sort\">\n"
"      <arg direction=\"in\" type=\"s\" name=\"field\"/>\n"
"    </method>\n"
"    <method name=\"contactsDetails\">\n"
"      <arg direction=\"in\" type=\"as\" name=\"fields\"/>\n"
"      <arg direction=\"in\" type=\"i\" name=\"startIndex\"/>\n"
"      <arg direction=\"in\" type=\"i\" name=\"pageSize\"/>\n"
"      <arg direction=\"out\" type=\"as\"/>\n"
"    </method>\n"
"    <method name=\"contactDetails\">\n"
"      <arg direction=\"in\" type=\"as\" name=\"fields\"/>\n"
"      <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
"      <arg direction=\"out\" type=\"s\"/>\n"
"    </method>\n"
"    <method name=\"close\"/>\n"
"  </interface>\n"
        "")
    Q_PROPERTY(int count READ count NOTIFY countChanged)
public:
    ViewAdaptor(const QDBusConnection &connection, View *parent);
    virtual ~ViewAdaptor();
    void destroy();

public Q_SLOTS:
    QString contactDetails(const QStringList &fields, const QString &id);
    QStringList contactsDetails(const QStringList &fields, int startIndex, int pageSize, const QDBusMessage &message);
    int count();
    void sort(const QString &field);
    void close();

Q_SIGNALS:
    void contactsAdded(int pos, int length);
    void contactsRemoved(int pos, int length);
    void contactsUpdated(int pos, int length);
    void countChanged(int count);

private:
    View *m_view;
    QDBusConnection m_connection;
};

} // namespace

#endif