~timo-jyrinki/telephony-service/rebuild_against_qt521

« back to all changes in this revision

Viewing changes to approver/greetercontacts.h

  • Committer: CI bot
  • Author(s): Michael Terry
  • Date: 2014-02-06 14:19:18 UTC
  • mfrom: (762.2.2 greeter)
  • Revision ID: ps-jenkins@lists.canonical.com-20140206141918-68sl1hbl9wcomb3s
Share current call contact info with the greeter. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Canonical, Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *  Michael Terry <michael.terry@canonical.com>
 
6
 *
 
7
 * This file is part of telephony-service.
 
8
 *
 
9
 * telephony-service is free software; you can redistribute it and/or modify
 
10
 * it under the terms of the GNU General Public License as published by
 
11
 * the Free Software Foundation; version 3.
 
12
 *
 
13
 * telephony-service is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
 */
 
21
 
 
22
#ifndef GREETERCONTACTS_H
 
23
#define GREETERCONTACTS_H
 
24
 
 
25
#include <QContact>
 
26
#include <QContactFilter>
 
27
#include <QDBusMessage>
 
28
#include <QObject>
 
29
 
 
30
class QDBusPendingCallWatcher;
 
31
 
 
32
/**
 
33
 * When running under the greeter, we don't have our own contacts database.
 
34
 * Instead, we query AccountsService for the information.
 
35
 */
 
36
class GreeterContacts : public QObject
 
37
{
 
38
    Q_OBJECT
 
39
 
 
40
public:
 
41
    GreeterContacts(QObject *parent = 0);
 
42
    ~GreeterContacts();
 
43
 
 
44
    void setFilter(const QtContacts::QContactFilter &filter);
 
45
 
 
46
    // Records contact info for currently-logged-in user
 
47
    static void emitContact(const QtContacts::QContact &contact);
 
48
 
 
49
    // These are really implementation details, but are public for ease of unit testing
 
50
    static QVariantMap contactToMap(const QtContacts::QContact &contact);
 
51
    static QtContacts::QContact mapToContact(const QVariantMap &map);
 
52
 
 
53
Q_SIGNALS:
 
54
    void contactUpdated(const QtContacts::QContact &contact);
 
55
 
 
56
private Q_SLOTS:
 
57
    void greeterPropertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidated);
 
58
    void accountsPropertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidated, const QDBusMessage &message);
 
59
 
 
60
    void greeterGetEntryReply(QDBusPendingCallWatcher *watcher);
 
61
    void accountsGetUsersReply(QDBusPendingCallWatcher *watcher);
 
62
    void accountsGetContactReply(QDBusPendingCallWatcher *watcher);
 
63
 
 
64
private:
 
65
    void queryEntry();
 
66
    void queryContact(const QString &user);
 
67
    void updateActiveUser(const QString &username);
 
68
    QtContacts::QContact lookupContact();
 
69
    void signalIfNeeded();
 
70
 
 
71
    QtContacts::QContactFilter mFilter;
 
72
    QString mActiveUser;
 
73
    QMap<QString, QVariantMap> mContacts;
 
74
};
 
75
 
 
76
#endif // GREETERCONTACTS_H