-
Notifications
You must be signed in to change notification settings - Fork 6
/
callchannelobserver.h
75 lines (58 loc) · 2.27 KB
/
callchannelobserver.h
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
#ifndef CALLCHANNELOBSERVER_H
#define CALLCHANNELOBSERVER_H
#include <TelepathyQt/AccountManager>
#include <TelepathyQt/SimpleCallObserver>
#include <TelepathyQt/PendingOperation>
#include <TelepathyQt/PendingReady>
#include <TelepathyQt/PendingAccount>
#include <TelepathyQt/CallChannel>
#include <QContactManager>
QTCONTACTS_USE_NAMESPACE
class TelepathyCallMonitor : public QObject
{
Q_OBJECT
public:
TelepathyCallMonitor(const Tp::AccountPtr& account):
mAccount(account),
mCallObserver(Tp::SimpleCallObserver::create(mAccount, Tp::SimpleCallObserver::CallDirectionIncoming)) {
connect(mCallObserver.data(), SIGNAL(callStarted(Tp::CallChannelPtr)), SIGNAL(callStarted(Tp::CallChannelPtr)));
// connect(mCallObserver.data(), SIGNAL(callEnded(Tp::CallChannelPtr,QString,QString)), SIGNAL(callEnded()));
// connect(mCallObserver.data(), SIGNAL(streamedMediaCallStarted(Tp::StreamedMediaChannelPtr)), SIGNAL(offHook()));
// connect(mCallObserver.data(), SIGNAL(streamedMediaCallEnded(Tp::StreamedMediaChannelPtr,QString,QString)), SIGNAL(onHook()));
}
signals:
void callStarted(Tp::CallChannelPtr callChannel);
// void callEnded();
private:
Tp::AccountPtr mAccount;
Tp::SimpleCallObserverPtr mCallObserver;
};
class TelepathyMonitor: public QObject
{
Q_OBJECT
public:
TelepathyMonitor(QObject *parent = 0);
void hangupCall(uint cookie);
void accept(uint cookie);
private slots:
void accountManagerSetup();
void accountManagerReady(Tp::PendingOperation* operation);
void newAccount(const Tp::AccountPtr& account);
void accountReady(Tp::PendingOperation* operation);
void onCallStarted(Tp::CallChannelPtr callChannel);
void callStateChanged(Tp::CallState state);
signals:
void incomingCall(uint cookie, const QString &number, const QString &name);
void callStarted(uint cookie);
void callEnded(uint cookie, bool missed);
private:
void checkAndAddAccount(const Tp::AccountPtr& account);
private:
Tp::AccountManagerPtr m_accountManager;
QList<TelepathyCallMonitor*> m_callMonitors;
QContactManager *m_contactManager;
QHash<uint, Tp::CallChannel*> m_currentCalls;
QHash<uint, Tp::CallState> m_currentCallStates;
uint m_cookie = 0;
};
#endif // CALLCHANNELOBSERVER_H