~ken-vandine/libqofono/0.90-suggests

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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/****************************************************************************
**
** Copyright (C) 2013-2014 Jolla Ltd.
** Contact: lorn.potter@jollamobile.com
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
****************************************************************************/

#ifndef QOFONOVoiceCall_H
#define QOFONOVoiceCall_H

#include "qofonoobject.h"
#include "qofono_global.h"

//! This class is used to access ofono voice call API
/*!
 * The API is documented in
 * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob;f=doc/voicecall-api.txt
 */
class QOFONOSHARED_EXPORT QOfonoVoiceCall : public QOfonoObject
{
    Q_OBJECT
    Q_ENUMS(Error)
    Q_PROPERTY(QString voiceCallPath READ voiceCallPath WRITE setVoiceCallPath NOTIFY voiceCallPathChanged)

    Q_PROPERTY(QString lineIdentification READ lineIdentification NOTIFY lineIdentificationChanged)
    Q_PROPERTY(QString incomingLine READ incomingLine NOTIFY incomingLineChanged)
    Q_PROPERTY(QString name READ name NOTIFY nameChanged)
    Q_PROPERTY(QString state READ state NOTIFY stateChanged)
    Q_PROPERTY(QString startTime READ startTime NOTIFY startTimeChanged)
    Q_PROPERTY(QString information READ information NOTIFY informationChanged)
    Q_PROPERTY(bool multiparty READ multiparty NOTIFY multipartyChanged)
    Q_PROPERTY(bool emergency READ emergency NOTIFY emergencyChanged)
    Q_PROPERTY(bool remoteHeld READ remoteHeld NOTIFY remoteHeldChanged)
    Q_PROPERTY(quint8 icon READ icon NOTIFY iconChanged)

public:
    enum Error {
        NoError,
        NotImplementedError,
        InProgressError,
        InvalidArgumentsError,
        InvalidFormatError,
        FailedError,
        UnknownError
    };
    explicit QOfonoVoiceCall(QObject *parent = 0);
    ~QOfonoVoiceCall();

    QString voiceCallPath() const;
    void setVoiceCallPath(const QString &path);

    QString lineIdentification() const;
    QString incomingLine() const;
    QString name() const;
    QString state() const;
    QString startTime() const;
    QString information() const;
    bool multiparty() const;
    bool emergency() const;
    quint8 icon() const;
    bool remoteHeld() const;
    bool remoteMultiparty() const;

    bool isValid() const;

Q_SIGNALS:
    void lineIdentificationChanged(const QString &name);
    void nameChanged(const QString &name);
    void stateChanged(const QString &state);
    void startTimeChanged(const QString &time);
    void informationChanged(const QString &mcc);
    void incomingLineChanged(const QString &line);
    void disconnectReason(const QString &reason);
    void multipartyChanged(bool multiparty);
    void iconChanged(const quint8 &icon);
    void emergencyChanged(bool emergency);
    void remoteHeldChanged(bool remoteHeld);
    void remoteMultipartyChanged(bool remoteMultiparty);

    void voiceCallPathChanged(const QString &path);

    void answerComplete(QOfonoVoiceCall::Error error, const QString &errorString);
    void hangupComplete(QOfonoVoiceCall::Error error, const QString &errorString);
    void deflectComplete(QOfonoVoiceCall::Error error, const QString &errorString);

public slots:
    void answer();
    void hangup();
    void deflect(const QString &number);

private:
    static Error errorNameToEnum(const QString &errorName);

private slots:
    void onDbusCallFinished(QDBusPendingCallWatcher *watch);

protected:
    QDBusAbstractInterface *createDbusInterface(const QString &path);
    void propertyChanged(const QString &key, const QVariant &value);
    void objectPathChanged(const QString &path, const QVariantMap *properties);
};

#endif // QOFONOVoiceCall_H