Initial Import
[profile/ivi/hfdialer.git] / src / callitem.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 CALLITEM_H
12 #define CALLITEM_H
13
14 #include <QString>
15 #include <QDateTime>
16 #include <QtDBus>
17 #include <MGConfItem>
18 #include "callproxy.h"
19
20 enum CallState {
21     STATE_NONE = 0,
22     STATE_ACTIVE,
23     STATE_HELD,
24     STATE_DIALING,
25     STATE_ALERTING,
26     STATE_INCOMING,
27     STATE_WAITING,
28     STATE_DISCONNECTED,
29     STATE_LAST,
30 };
31
32 enum CallDirection {
33     DIRECTION_NONE = 0,
34     DIRECTION_IN,
35     DIRECTION_OUT,
36     DIRECTION_MISSED,
37     DIRECTION_LAST,
38 };
39
40 enum CallDisconnectReason {
41     DISCONNECT_NONE = 0,
42     DISCONNECT_LOCAL,
43     DISCONNECT_REMOTE,
44     DISCONNECT_NETWORK,
45     DISCONNECT_LAST,
46 };
47
48 class CallItem: public QObject 
49 {
50     Q_OBJECT
51
52     Q_PROPERTY(QString path READ path WRITE setPath)
53         Q_PROPERTY(QString lineID READ lineID)
54         Q_PROPERTY(QString name READ name)
55         Q_PROPERTY(CallState state READ state)
56         Q_PROPERTY(CallDirection direction READ direction WRITE setDirection)
57         Q_PROPERTY(CallDisconnectReason reason READ reason)
58         Q_PROPERTY(int duration READ duration)
59         Q_PROPERTY(QDateTime startTime READ startTime)
60         Q_PROPERTY(bool multiparty READ multiparty)
61         Q_PROPERTY(CallProxy* callProxy READ callProxy)
62
63         public:
64         CallItem(const QString path = QString(), QObject *parent = 0);
65     virtual ~CallItem();
66
67     QString path() const;
68     QString lineID() const;
69     QString name() const;
70     CallState state() const;
71     CallDirection direction() const;
72     CallDisconnectReason reason() const;
73     int duration() const;
74     QDateTime startTime() const;
75     CallProxy *callProxy() const;
76     bool isValid();
77     bool isValid() const;
78     bool multiparty();
79
80 public Q_SLOTS:
81     void init();
82     bool setPath(QString path);  // Setting this will create the CallProxy
83     void setDirection(CallDirection direction);
84     void click();
85
86     void silenceRingtone();
87
88 Q_SIGNALS:
89     // TODO: handle tap-and-hold
90     void clicked();
91     void stateChanged();
92     void dataChanged();
93     void multipartyChanged();
94
95 private Q_SLOTS:
96     void callStateChanged();
97     void callDataChanged();
98     void callDisconnected(const QString &reason);
99     void callMultipartyChanged();
100
101 private:
102     QString               m_path;
103     MGConfItem           *m_rtKey;
104     bool                  m_isconnected;
105     QString               m_ringtonefile;
106     CallProxy            *m_call;
107
108     Q_DISABLE_COPY(CallItem)
109 };
110
111 #endif // CALLITEM_H
112
113 /* Local Variables:      */
114 /* mode:c++              */
115 /* c-basic-offset:4      */
116 /* indent-tabs-mode: nil */
117 /* End:                  */