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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
/*
* Copyright (C) 2012 Canonical, Ltd.
*
* Authors:
* Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
* Tiago Salem Herrmann <tiago.herrmann@canonical.com>
*
* This file is part of telephony-service.
*
* telephony-service 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.
*
* telephony-service 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 CALLENTRY_H
#define CALLENTRY_H
#include <QQmlListProperty>
#include <QObject>
#include <QTime>
#include <TelepathyQt/CallChannel>
#include "audiooutput.h"
class AccountEntry;
class CallEntry : public QObject
{
Q_OBJECT
Q_PROPERTY (bool held
READ isHeld
WRITE setHold
NOTIFY heldChanged)
Q_PROPERTY(bool muted
READ isMuted
WRITE setMute
NOTIFY mutedChanged)
Q_PROPERTY(bool voicemail
READ isVoicemail
WRITE setVoicemail
NOTIFY voicemailChanged)
Q_PROPERTY(AccountEntry *account READ account)
// FIXME: replace this by a more generic identifier to support accounts not based on phone numbers
// this property is only filled for 1-1 calls
Q_PROPERTY(QString phoneNumber
READ phoneNumber
NOTIFY phoneNumberChanged)
// this property is only filled for conference calls
Q_PROPERTY(QQmlListProperty<CallEntry> calls
READ calls
NOTIFY callsChanged)
Q_PROPERTY(bool isConference
READ isConference
NOTIFY isConferenceChanged)
Q_PROPERTY(int elapsedTime
READ elapsedTime
NOTIFY elapsedTimeChanged)
Q_PROPERTY(bool active
READ isActive
NOTIFY activeChanged)
Q_PROPERTY(bool dialing
READ dialing
NOTIFY dialingChanged)
Q_PROPERTY(bool incoming
READ incoming
NOTIFY incomingChanged)
Q_PROPERTY(bool ringing
READ ringing
NOTIFY ringingChanged)
Q_PROPERTY(QString dtmfString
READ dtmfString
NOTIFY dtmfStringChanged)
Q_PROPERTY(QString activeAudioOutput
READ activeAudioOutput
WRITE setActiveAudioOutput
NOTIFY activeAudioOutputChanged)
Q_PROPERTY(QQmlListProperty<AudioOutput> audioOutputs
READ audioOutputs
NOTIFY audioOutputsChanged)
public:
explicit CallEntry(const Tp::CallChannelPtr &channel, QObject *parent = 0);
void timerEvent(QTimerEvent *event);
bool isHeld() const;
void setHold(bool hold);
bool isMuted() const;
void setMute(bool value);
bool isVoicemail() const;
void setVoicemail(bool voicemail);
int elapsedTime() const;
bool isActive() const;
void setActiveAudioOutput(const QString &id);
QString activeAudioOutput() const;
QQmlListProperty<AudioOutput> audioOutputs();
bool dialing() const;
bool incoming() const;
bool ringing() const;
QString phoneNumber() const;
QQmlListProperty<CallEntry> calls();
bool isConference() const;
QString dtmfString() const;
Q_INVOKABLE void sendDTMF(const QString &key);
Q_INVOKABLE void endCall();
Q_INVOKABLE void splitCall();
Tp::CallChannelPtr channel() const;
AccountEntry *account() const;
// QQmlListProperty helpers
static int callsCount(QQmlListProperty<CallEntry> *p);
static CallEntry* callAt(QQmlListProperty<CallEntry> *p, int index);
void addCall(CallEntry *call);
static int audioOutputsCount(QQmlListProperty<AudioOutput> *p);
static AudioOutput* audioOutputsAt(QQmlListProperty<AudioOutput> *p, int index);
protected Q_SLOTS:
void onCallStateChanged(Tp::CallState state);
void onCallFlagsChanged(Tp::CallFlags flags);
void onCallLocalHoldStateChanged(Tp::LocalHoldState state, Tp::LocalHoldStateReason reason);
void onMutedChanged(uint state);
void onCallPropertiesChanged(const QString &objectPath, const QVariantMap &properties);
void onAudioOutputsChanged(const AudioOutputDBusList &outputs);
void onActiveAudioOutputChanged(const QString &id);
// conference related stuff
void onConferenceChannelMerged(const Tp::ChannelPtr &channel);
void onConferenceChannelRemoved(const Tp::ChannelPtr &channel, const Tp::Channel::GroupMemberChangeDetails &details);
void onInternalCallEnded();
// handler error notification
void onCallHoldingFailed(const QString &objectPath);
protected:
void setupCallChannel();
void updateChannelProperties(const QVariantMap &properties = QVariantMap());
Q_SIGNALS:
void callEnded();
void callActive();
void activeChanged();
void heldChanged();
void mutedChanged();
void voicemailChanged();
void phoneNumberChanged();
void callsChanged();
void isConferenceChanged();
void dtmfStringChanged();
void dialingChanged();
void incomingChanged();
void ringingChanged();
void elapsedTimeChanged();
void activeAudioOutputChanged();
void audioOutputsChanged();
void callHoldingFailed();
private:
void refreshProperties();
AccountEntry *mAccount;
Tp::CallChannelPtr mChannel;
QDBusInterface mMuteInterface;
QDBusInterface mAudioOutputsInterface;
QMap<QString, QVariant> mProperties;
bool mVoicemail;
bool mLocalMuteState;
QDateTime mActiveTimestamp;
QList<CallEntry*> mCalls;
QList<AudioOutput*> mAudioOutputs;
QString mActiveAudioOutput;
};
#endif // CALLENTRY_H
|