QXmpp  Version:0.7.5
 All Classes Functions Variables Enumerations Enumerator Properties Groups
QXmppCallManager.h
1 /*
2  * Copyright (C) 2008-2012 The QXmpp developers
3  *
4  * Author:
5  * Jeremy LainĂ©
6  *
7  * Source:
8  * http://code.google.com/p/qxmpp
9  *
10  * This file is a part of QXmpp library.
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  */
23 
24 #ifndef QXMPPCALLMANAGER_H
25 #define QXMPPCALLMANAGER_H
26 
27 #include <QObject>
28 #include <QIODevice>
29 #include <QMetaType>
30 
31 #include "QXmppClientExtension.h"
32 #include "QXmppLogger.h"
33 
34 class QHostAddress;
35 class QXmppCallPrivate;
36 class QXmppCallManager;
37 class QXmppCallManagerPrivate;
38 class QXmppIq;
40 class QXmppJingleIq;
42 class QXmppPresence;
45 
52 
53 class QXMPP_EXPORT QXmppCall : public QXmppLoggable
54 {
55  Q_OBJECT
56  Q_ENUMS(Direction State)
57  Q_FLAGS(QIODevice::OpenModeFlag QIODevice::OpenMode)
58  Q_PROPERTY(Direction direction READ direction CONSTANT)
59  Q_PROPERTY(QString jid READ jid CONSTANT)
60  Q_PROPERTY(State state READ state NOTIFY stateChanged)
61  Q_PROPERTY(QIODevice::OpenMode audioMode READ audioMode NOTIFY audioModeChanged)
62  Q_PROPERTY(QIODevice::OpenMode videoMode READ videoMode NOTIFY videoModeChanged)
63 
64 public:
66  enum Direction
67  {
70  };
71 
73  enum State
74  {
75  ConnectingState = 0,
76  ActiveState = 1,
77  DisconnectingState = 2,
78  FinishedState = 3,
79  };
80 
81  ~QXmppCall();
82 
83  QXmppCall::Direction direction() const;
84  QString jid() const;
85  QString sid() const;
86  QXmppCall::State state() const;
87 
88  QXmppRtpAudioChannel *audioChannel() const;
89  QIODevice::OpenMode audioMode() const;
90  QXmppRtpVideoChannel *videoChannel() const;
91  QIODevice::OpenMode videoMode() const;
92 
93 signals:
99  void connected();
100 
105  void finished();
106 
108  void ringing();
109 
111  void stateChanged(QXmppCall::State state);
112 
114  void audioModeChanged(QIODevice::OpenMode mode);
115 
117  void videoModeChanged(QIODevice::OpenMode mode);
118 
119 public slots:
120  void accept();
121  void hangup();
122  void startVideo();
123  void stopVideo();
124 
125 private slots:
126  void localCandidatesChanged();
127  void terminated();
128  void updateOpenMode();
129 
130 private:
131  QXmppCall(const QString &jid, QXmppCall::Direction direction, QXmppCallManager *parent);
132 
133  QXmppCallPrivate *d;
134  friend class QXmppCallManager;
135  friend class QXmppCallManagerPrivate;
136  friend class QXmppCallPrivate;
137 };
138 
159 
160 class QXMPP_EXPORT QXmppCallManager : public QXmppClientExtension
161 {
162  Q_OBJECT
163 
164 public:
166  ~QXmppCallManager();
167  void setStunServer(const QHostAddress &host, quint16 port = 3478);
168  void setTurnServer(const QHostAddress &host, quint16 port = 3478);
169  void setTurnUser(const QString &user);
170  void setTurnPassword(const QString &password);
171 
173  QStringList discoveryFeatures() const;
174  bool handleStanza(const QDomElement &element);
176 
177 signals:
182  void callReceived(QXmppCall *call);
183 
185  void callStarted(QXmppCall *call);
186 
187 public slots:
188  QXmppCall *call(const QString &jid);
189 
190 protected:
192  void setClient(QXmppClient* client);
194 
195 private slots:
196  void _q_callDestroyed(QObject *object);
197  void _q_disconnected();
198  void _q_iqReceived(const QXmppIq &iq);
199  void _q_jingleIqReceived(const QXmppJingleIq &iq);
200  void _q_presenceReceived(const QXmppPresence &presence);
201 
202 private:
203  QXmppCallManagerPrivate *d;
204  friend class QXmppCall;
205  friend class QXmppCallPrivate;
206  friend class QXmppCallManagerPrivate;
207 };
208 
209 Q_DECLARE_METATYPE(QXmppCall::State)
210 
211 #endif