QXmpp  Version:0.9.1
QXmppJingleIq.h
1 /*
2  * Copyright (C) 2008-2014 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 QXmppJingleIqContentPrivate;
32 
36 
37 class QXMPP_EXPORT QXmppJinglePayloadType
38 {
39 public:
41 
42  unsigned char channels() const;
43  void setChannels(unsigned char channels);
44 
45  unsigned int clockrate() const;
46  void setClockrate(unsigned int clockrate);
47 
48  unsigned char id() const;
49  void setId(unsigned char id);
50 
51  unsigned int maxptime() const;
52  void setMaxptime(unsigned int maxptime);
53 
54  QString name() const;
55  void setName(const QString &name);
56 
57  QMap<QString, QString> parameters() const;
58  void setParameters(const QMap<QString, QString> &parameters);
59 
60  unsigned int ptime() const;
61  void setPtime(unsigned int ptime);
62 
64  void parse(const QDomElement &element);
65  void toXml(QXmlStreamWriter *writer) const;
67 
68  bool operator==(const QXmppJinglePayloadType &other) const;
69 
70 private:
71  unsigned char m_channels;
72  unsigned int m_clockrate;
73  unsigned char m_id;
74  unsigned int m_maxptime;
75  QString m_name;
76  QMap<QString, QString> m_parameters;
77  unsigned int m_ptime;
78 };
79 
83 
84 class QXMPP_EXPORT QXmppJingleCandidate
85 {
86 public:
88  enum Type
89  {
91  PeerReflexiveType,
92  ServerReflexiveType,
94  RelayedType
96  };
98 
100 
101  int component() const;
102  void setComponent(int component);
103 
104  QString foundation() const;
105  void setFoundation(const QString &foundation);
106 
107  int generation() const;
108  void setGeneration(int generation);
109 
110  QHostAddress host() const;
111  void setHost(const QHostAddress &host);
112 
113  QString id() const;
114  void setId(const QString &id);
115 
116  int network() const;
117  void setNetwork(int network);
118 
119  quint16 port() const;
120  void setPort(quint16 port);
121 
122  int priority() const;
123  void setPriority(int priority);
124 
125  QString protocol() const;
126  void setProtocol(const QString &protocol);
127 
128  QXmppJingleCandidate::Type type() const;
129  void setType(QXmppJingleCandidate::Type);
130 
131  bool isNull() const;
132 
134  void parse(const QDomElement &element);
135  void toXml(QXmlStreamWriter *writer) const;
136 
137  static QXmppJingleCandidate::Type typeFromString(const QString &typeStr, bool *ok = 0);
138  static QString typeToString(QXmppJingleCandidate::Type type);
140 
141 private:
142  int m_component;
143  QString m_foundation;
144  int m_generation;
145  QHostAddress m_host;
146  QString m_id;
147  int m_network;
148  quint16 m_port;
149  QString m_protocol;
150  int m_priority;
152 };
153 
158 
159 class QXMPP_EXPORT QXmppJingleIq : public QXmppIq
160 {
161 public:
163  enum Action {
164  ContentAccept,
165  ContentAdd,
166  ContentModify,
167  ContentReject,
168  ContentRemove,
169  DescriptionInfo,
170  SecurityInfo,
171  SessionAccept,
172  SessionInfo,
173  SessionInitiate,
174  SessionTerminate,
175  TransportAccept,
176  TransportInfo,
177  TransportReject,
178  TransportReplace
179  };
180 
185 
186  class QXMPP_EXPORT Content
187  {
188  public:
189  Content();
190  Content(const QXmppJingleIq::Content &other);
191  ~Content();
192 
193  QString creator() const;
194  void setCreator(const QString &creator);
195 
196  QString name() const;
197  void setName(const QString &name);
198 
199  QString senders() const;
200  void setSenders(const QString &senders);
201 
202  // XEP-0167: Jingle RTP Sessions
203  QString descriptionMedia() const;
204  void setDescriptionMedia(const QString &media);
205 
206  quint32 descriptionSsrc() const;
207  void setDescriptionSsrc(quint32 ssrc);
208 
209  void addPayloadType(const QXmppJinglePayloadType &payload);
210  QList<QXmppJinglePayloadType> payloadTypes() const;
211  void setPayloadTypes(const QList<QXmppJinglePayloadType> &payloadTypes);
212 
213  void addTransportCandidate(const QXmppJingleCandidate &candidate);
214  QList<QXmppJingleCandidate> transportCandidates() const;
215 
216  QString transportUser() const;
217  void setTransportUser(const QString &user);
218 
219  QString transportPassword() const;
220  void setTransportPassword(const QString &password);
221 
222  // XEP-0320: Use of DTLS-SRTP in Jingle Sessions
223  QByteArray transportFingerprint() const;
224  void setTransportFingerprint(const QByteArray &fingerprint);
225 
226  QString transportFingerprintHash() const;
227  void setTransportFingerprintHash(const QString &hash);
228 
229  QString transportFingerprintSetup() const;
230  void setTransportFingerprintSetup(const QString &setup);
231 
233  void parse(const QDomElement &element);
234  void toXml(QXmlStreamWriter *writer) const;
235 
236  bool parseSdp(const QString &sdp);
237  QString toSdp() const;
239 
240  private:
241  QSharedDataPointer<QXmppJingleIqContentPrivate> d;
242  };
243 
248 
249  class QXMPP_EXPORT Reason
250  {
251  public:
252  enum Type {
253  None,
254  AlternativeSession,
255  Busy,
256  Cancel,
257  ConnectivityError,
258  Decline,
259  Expired,
260  FailedApplication,
261  FailedTransport,
262  GeneralError,
263  Gone,
264  IncompatibleParameters,
265  MediaError,
266  SecurityError,
267  Success,
268  Timeout,
269  UnsupportedApplications,
270  UnsupportedTransports
271  };
272 
273  Reason();
274 
275  QString text() const;
276  void setText(const QString &text);
277 
278  Type type() const;
279  void setType(Type type);
280 
282  void parse(const QDomElement &element);
283  void toXml(QXmlStreamWriter *writer) const;
285 
286  private:
287  QString m_text;
288  Type m_type;
289  };
290 
291  QXmppJingleIq();
292 
293  Action action() const;
294  void setAction(Action action);
295 
296  QString initiator() const;
297  void setInitiator(const QString &initiator);
298 
299  QString responder() const;
300  void setResponder(const QString &responder);
301 
302  QString sid() const;
303  void setSid(const QString &sid);
304 
306  Content& content() { return m_content; };
307 
309  const Content& content() const { return m_content; };
310 
312  Reason& reason() { return m_reason; };
313 
315  const Reason& reason() const { return m_reason; };
316 
317  // XEP-0167: Jingle RTP Sessions
318  bool ringing() const;
319  void setRinging(bool ringing);
320 
322  static bool isJingleIq(const QDomElement &element);
324 
325 protected:
327  void parseElementFromChild(const QDomElement &element);
328  void toXmlElementFromChild(QXmlStreamWriter *writer) const;
330 
331 private:
332  Action m_action;
333  QString m_initiator;
334  QString m_responder;
335  QString m_sid;
336 
337  Content m_content;
338  Reason m_reason;
339  bool m_ringing;
340 };
341 
342 #endif
The QXmppJingleIq class represents an IQ used for initiating media sessions as specified by XEP-0166:...
Definition: QXmppJingleIq.h:159
const Content & content() const
Returns a const reference to the IQ's content element.
Definition: QXmppJingleIq.h:309
Action
This enum is used to describe a Jingle action.
Definition: QXmppJingleIq.h:163
The QXmppJinglePayloadType class represents a payload type as specified by XEP-0167: Jingle RTP Sessi...
Definition: QXmppJingleIq.h:37
const Reason & reason() const
Returns a const reference to the IQ's reason element.
Definition: QXmppJingleIq.h:315
Host candidate, a local address/port.
Definition: QXmppJingleIq.h:90
Type
This enum is used to describe a candidate's type.
Definition: QXmppJingleIq.h:88
Reason & reason()
Returns a reference to the IQ's reason element.
Definition: QXmppJingleIq.h:312
Content & content()
Returns a reference to the IQ's content element.
Definition: QXmppJingleIq.h:306
The QXmppIq class is the base class for all IQs.
Definition: QXmppIq.h:42
The QXmppJingleCandidate class represents a transport candidate as specified by XEP-0176: Jingle ICE-...
Definition: QXmppJingleIq.h:84