QXmpp  Version:1.0.0
QXmppJingleIq.h
1 /*
2  * Copyright (C) 2008-2019 The QXmpp developers
3  *
4  * Author:
5  * Jeremy LainĂ©
6  *
7  * Source:
8  * https://github.com/qxmpp-project/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 QXMPPJINGLEIQ_H
25 #define QXMPPJINGLEIQ_H
26 
27 #include <QHostAddress>
28 
29 #include "QXmppIq.h"
30 
31 class QXmppJingleCandidatePrivate;
32 class QXmppJingleIqContentPrivate;
33 class QXmppJingleIqPrivate;
34 class QXmppJinglePayloadTypePrivate;
35 
39 
40 class QXMPP_EXPORT QXmppJinglePayloadType
41 {
42 public:
46 
47  unsigned char channels() const;
48  void setChannels(unsigned char channels);
49 
50  unsigned int clockrate() const;
51  void setClockrate(unsigned int clockrate);
52 
53  unsigned char id() const;
54  void setId(unsigned char id);
55 
56  unsigned int maxptime() const;
57  void setMaxptime(unsigned int maxptime);
58 
59  QString name() const;
60  void setName(const QString &name);
61 
62  QMap<QString, QString> parameters() const;
63  void setParameters(const QMap<QString, QString> &parameters);
64 
65  unsigned int ptime() const;
66  void setPtime(unsigned int ptime);
67 
69  void parse(const QDomElement &element);
70  void toXml(QXmlStreamWriter *writer) const;
72 
73  QXmppJinglePayloadType& operator=(const QXmppJinglePayloadType &other);
74  bool operator==(const QXmppJinglePayloadType &other) const;
75 
76 private:
77  QSharedDataPointer<QXmppJinglePayloadTypePrivate> d;
78 };
79 
83 
84 class QXMPP_EXPORT QXmppJingleCandidate
85 {
86 public:
88  enum Type
89  {
91  PeerReflexiveType,
92  ServerReflexiveType,
94  RelayedType
96  };
98 
102 
103  QXmppJingleCandidate& operator=(const QXmppJingleCandidate &other);
104 
105  int component() const;
106  void setComponent(int component);
107 
108  QString foundation() const;
109  void setFoundation(const QString &foundation);
110 
111  int generation() const;
112  void setGeneration(int generation);
113 
114  QHostAddress host() const;
115  void setHost(const QHostAddress &host);
116 
117  QString id() const;
118  void setId(const QString &id);
119 
120  int network() const;
121  void setNetwork(int network);
122 
123  quint16 port() const;
124  void setPort(quint16 port);
125 
126  int priority() const;
127  void setPriority(int priority);
128 
129  QString protocol() const;
130  void setProtocol(const QString &protocol);
131 
132  QXmppJingleCandidate::Type type() const;
133  void setType(QXmppJingleCandidate::Type);
134 
135  bool isNull() const;
136 
138  void parse(const QDomElement &element);
139  void toXml(QXmlStreamWriter *writer) const;
140 
141  static QXmppJingleCandidate::Type typeFromString(const QString &typeStr, bool *ok = 0);
142  static QString typeToString(QXmppJingleCandidate::Type type);
144 
145 private:
146  QSharedDataPointer<QXmppJingleCandidatePrivate> d;
147 };
148 
153 
154 class QXMPP_EXPORT QXmppJingleIq : public QXmppIq
155 {
156 public:
158  enum Action {
159  ContentAccept,
160  ContentAdd,
161  ContentModify,
162  ContentReject,
163  ContentRemove,
164  DescriptionInfo,
165  SecurityInfo,
166  SessionAccept,
167  SessionInfo,
168  SessionInitiate,
169  SessionTerminate,
170  TransportAccept,
171  TransportInfo,
172  TransportReject,
173  TransportReplace
174  };
175 
180 
181  class QXMPP_EXPORT Content
182  {
183  public:
184  Content();
185  Content(const QXmppJingleIq::Content &other);
186  ~Content();
187 
188  Content& operator=(const Content &other);
189 
190  QString creator() const;
191  void setCreator(const QString &creator);
192 
193  QString name() const;
194  void setName(const QString &name);
195 
196  QString senders() const;
197  void setSenders(const QString &senders);
198 
199  // XEP-0167: Jingle RTP Sessions
200  QString descriptionMedia() const;
201  void setDescriptionMedia(const QString &media);
202 
203  quint32 descriptionSsrc() const;
204  void setDescriptionSsrc(quint32 ssrc);
205 
206  void addPayloadType(const QXmppJinglePayloadType &payload);
207  QList<QXmppJinglePayloadType> payloadTypes() const;
208  void setPayloadTypes(const QList<QXmppJinglePayloadType> &payloadTypes);
209 
210  void addTransportCandidate(const QXmppJingleCandidate &candidate);
211  QList<QXmppJingleCandidate> transportCandidates() const;
212  void setTransportCandidates(const QList<QXmppJingleCandidate> &candidates);
213 
214  QString transportUser() const;
215  void setTransportUser(const QString &user);
216 
217  QString transportPassword() const;
218  void setTransportPassword(const QString &password);
219 
220  // XEP-0320: Use of DTLS-SRTP in Jingle Sessions
221  QByteArray transportFingerprint() const;
222  void setTransportFingerprint(const QByteArray &fingerprint);
223 
224  QString transportFingerprintHash() const;
225  void setTransportFingerprintHash(const QString &hash);
226 
227  QString transportFingerprintSetup() const;
228  void setTransportFingerprintSetup(const QString &setup);
229 
231  void parse(const QDomElement &element);
232  void toXml(QXmlStreamWriter *writer) const;
233 
234  bool parseSdp(const QString &sdp);
235  QString toSdp() const;
237 
238  private:
239  QSharedDataPointer<QXmppJingleIqContentPrivate> d;
240  };
241 
246 
247  class QXMPP_EXPORT Reason
248  {
249  public:
251  enum Type {
252  None,
253  AlternativeSession,
254  Busy,
255  Cancel,
256  ConnectivityError,
257  Decline,
258  Expired,
259  FailedApplication,
260  FailedTransport,
261  GeneralError,
262  Gone,
263  IncompatibleParameters,
264  MediaError,
265  SecurityError,
266  Success,
267  Timeout,
268  UnsupportedApplications,
269  UnsupportedTransports
270  };
271 
272  Reason();
273 
274  QString text() const;
275  void setText(const QString &text);
276 
277  Type type() const;
278  void setType(Type type);
279 
281  void parse(const QDomElement &element);
282  void toXml(QXmlStreamWriter *writer) const;
284 
285  private:
286  QString m_text;
287  Type m_type;
288  };
289 
290  QXmppJingleIq();
291  QXmppJingleIq(const QXmppJingleIq &other);
292  ~QXmppJingleIq();
293 
294  QXmppJingleIq& operator=(const QXmppJingleIq &other);
295 
296  Action action() const;
297  void setAction(Action action);
298 
299  void addContent(const Content &content);
300  QList<Content> contents() const;
301  void setContents(const QList<Content> &contents);
302 
303  QString initiator() const;
304  void setInitiator(const QString &initiator);
305 
306  Reason& reason();
307  const Reason& reason() const;
308 
309  QString responder() const;
310  void setResponder(const QString &responder);
311 
312  // XEP-0167: Jingle RTP Sessions
313  bool ringing() const;
314  void setRinging(bool ringing);
315 
316  QString sid() const;
317  void setSid(const QString &sid);
318 
320  static bool isJingleIq(const QDomElement &element);
322 
323 protected:
325  void parseElementFromChild(const QDomElement &element);
326  void toXmlElementFromChild(QXmlStreamWriter *writer) const;
328 
329 private:
330  QSharedDataPointer<QXmppJingleIqPrivate> d;
331 };
332 
333 #endif
QXmppJinglePayloadType
The QXmppJinglePayloadType class represents a payload type as specified by XEP-0167: Jingle RTP Sessi...
Definition: QXmppJingleIq.h:40
QXmppJingleCandidate::Type
Type
This enum is used to describe a candidate's type.
Definition: QXmppJingleIq.h:88
QXmppJingleIq
The QXmppJingleIq class represents an IQ used for initiating media sessions as specified by XEP-0166:...
Definition: QXmppJingleIq.h:154
QXmppJingleCandidate::HostType
Host candidate, a local address/port.
Definition: QXmppJingleIq.h:90
QXmppJingleCandidate
The QXmppJingleCandidate class represents a transport candidate as specified by XEP-0176: Jingle ICE-...
Definition: QXmppJingleIq.h:84
QXmppIq
The QXmppIq class is the base class for all IQs.
Definition: QXmppIq.h:42
QXmppJingleIq::Action
Action
This enum is used to describe a Jingle action.
Definition: QXmppJingleIq.h:158