83c35b73931a1d7dbd950dc608932b4ab6958a0b
[profile/ivi/hfdialer.git] / src / callproxy.h
1 /*
2  * hfdialer - Hands Free Voice Call Manager
3  * Copyright (c) 2012, Intel Corporation.
4  *
5  * This program is licensed under the terms and conditions of the
6  * Apache License, version 2.0.  The full text of the Apache License is at
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  */
10
11 #ifndef CALLPROXY_H
12 #define CALLPROXY_H
13
14 #include "voicecall_interface.h"
15 #include <QtDBus>
16 #include <QDebug>
17
18 #define OFONO_SERVICE "org.ofono"
19 #define OFONO_MANAGER_PATH "/"
20
21 #define DEFAULT_CLIR "default"
22
23 class CallProxy: public org::ofono::VoiceCall
24 {
25     Q_OBJECT
26
27     Q_PROPERTY(QString   lineID READ lineID)
28     Q_PROPERTY(QString   name READ name)
29     Q_PROPERTY(QString   state READ state)
30     Q_PROPERTY(QDateTime startTime READ startTime)
31     Q_PROPERTY(int       duration READ duration)
32     Q_PROPERTY(QString   reason READ reason)
33     Q_PROPERTY(bool   multiparty READ multiparty)
34
35 public:
36     CallProxy(const QString &callPath);
37     virtual ~CallProxy();
38     bool isValid();
39
40     QString lineID() const;
41     QString name() const;
42     QString state() const;
43     QDateTime startTime() const;
44     int duration() const;
45     QString reason() const;
46     bool multiparty() const;
47
48 public Q_SLOTS:
49     // Answers the incoming call
50     // NOTE: only valid if state is incoming
51     void answer();
52
53     // Deflects the incoming or waiting call to number provided.
54     // NOTE: only valid if state is incoming or waiting
55     void deflect(const QString toNumber);
56
57     // Hangs up the voice call
58     void hangup();
59
60 Q_SIGNALS:
61     void callDisconnected(const QString &reason);
62     void stateChanged();
63     void dataChanged();
64     void multipartyChanged();
65
66 private Q_SLOTS:
67     // Slots to handle asyncronous DBus replies
68     void getPropertiesFinished(QDBusPendingCallWatcher *watcher);
69     void answerFinished(QDBusPendingCallWatcher *watcher);
70     void deflectFinished(QDBusPendingCallWatcher *watcher);
71     void hangupFinished(QDBusPendingCallWatcher *watcher);
72
73     // Slots to handle DBus signals from ofono
74     void propertyChanged(const QString &in0, const QDBusVariant &in1);
75     void disconnectReason(const QString &in0);
76
77     void proceedCallAnswer();
78     void deniedCallAnswer();
79
80 private:
81     void setStartTimeFromString(const QString &val);
82
83 private:
84     QStringList        m_properties;
85     QString            m_lineid;
86     QString            m_name;
87     QString            m_state;
88     QDateTime          m_startTime;
89     QString            m_reason;
90     bool               m_connected;
91     bool               m_multiparty;
92
93     Q_DISABLE_COPY(CallProxy)
94 };
95
96 #endif // CALLPROXY_H