QXmpp  Version:0.8.0
 All Classes Functions Variables Enumerations Enumerator Properties Groups
QXmppJingleIq.h
1 /*
2  * Copyright (C) 2008-2014 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 QXMPPJINGLEIQ_H
25 #define QXMPPJINGLEIQ_H
26 
27 #include <QHostAddress>
28 
29 #include "QXmppIq.h"
30 
34 
35 class QXMPP_EXPORT QXmppJinglePayloadType
36 {
37 public:
39 
40  unsigned char channels() const;
41  void setChannels(unsigned char channels);
42 
43  unsigned int clockrate() const;
44  void setClockrate(unsigned int clockrate);
45 
46  unsigned char id() const;
47  void setId(unsigned char id);
48 
49  unsigned int maxptime() const;
50  void setMaxptime(unsigned int maxptime);
51 
52  QString name() const;
53  void setName(const QString &name);
54 
55  QMap<QString, QString> parameters() const;
56  void setParameters(const QMap<QString, QString> &parameters);
57 
58  unsigned int ptime() const;
59  void setPtime(unsigned int ptime);
60 
62  void parse(const QDomElement &element);
63  void toXml(QXmlStreamWriter *writer) const;
65 
66  bool operator==(const QXmppJinglePayloadType &other) const;
67 
68 private:
69  unsigned char m_channels;
70  unsigned int m_clockrate;
71  unsigned char m_id;
72  unsigned int m_maxptime;
73  QString m_name;
74  QMap<QString, QString> m_parameters;
75  unsigned int m_ptime;
76 };
77 
81 
82 class QXMPP_EXPORT QXmppJingleCandidate
83 {
84 public:
86  enum Type
87  {
89  PeerReflexiveType,
90 
91  ServerReflexiveType,
92 
93  RelayedType,
94 
95  };
96 
98 
99  int component() const;
100  void setComponent(int component);
101 
102  int foundation() const;
103  void setFoundation(int foundation);
104 
105  QHostAddress host() const;
106  void setHost(const QHostAddress &host);
107 
108  QString id() const;
109  void setId(const QString &id);
110 
111  int network() const;
112  void setNetwork(int network);
113 
114  quint16 port() const;
115  void setPort(quint16 port);
116 
117  int priority() const;
118  void setPriority(int priority);
119 
120  QString protocol() const;
121  void setProtocol(const QString &protocol);
122 
123  QXmppJingleCandidate::Type type() const;
124  void setType(QXmppJingleCandidate::Type);
125 
126  bool isNull() const;
127 
129  void parse(const QDomElement &element);
130  void toXml(QXmlStreamWriter *writer) const;
131 
132  static QXmppJingleCandidate::Type typeFromString(const QString &typeStr, bool *ok = 0);
133  static QString typeToString(QXmppJingleCandidate::Type type);
135 
136 private:
137  int m_component;
138  int m_foundation;
139  int m_generation;
140  QHostAddress m_host;
141  QString m_id;
142  int m_network;
143  quint16 m_port;
144  QString m_protocol;
145  int m_priority;
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 
186  QString creator() const;
187  void setCreator(const QString &creator);
188 
189  QString name() const;
190  void setName(const QString &name);
191 
192  QString senders() const;
193  void setSenders(const QString &senders);
194 
195  // XEP-0167: Jingle RTP Sessions
196  QString descriptionMedia() const;
197  void setDescriptionMedia(const QString &media);
198 
199  void addPayloadType(const QXmppJinglePayloadType &payload);
200  QList<QXmppJinglePayloadType> payloadTypes() const;
201  void setPayloadTypes(const QList<QXmppJinglePayloadType> &payloadTypes);
202 
203  void addTransportCandidate(const QXmppJingleCandidate &candidate);
204  QList<QXmppJingleCandidate> transportCandidates() const;
205 
206  QString transportUser() const;
207  void setTransportUser(const QString &user);
208 
209  QString transportPassword() const;
210  void setTransportPassword(const QString &password);
211 
213  void parse(const QDomElement &element);
214  void toXml(QXmlStreamWriter *writer) const;
216 
217  private:
218  QString m_creator;
219  QString m_disposition;
220  QString m_name;
221  QString m_senders;
222 
223  QString m_descriptionMedia;
224  QString m_descriptionType;
225  QString m_transportType;
226  QString m_transportUser;
227  QString m_transportPassword;
228  QList<QXmppJinglePayloadType> m_payloadTypes;
229  QList<QXmppJingleCandidate> m_transportCandidates;
230  };
231 
236 
237  class QXMPP_EXPORT Reason
238  {
239  public:
240  enum Type {
241  None,
242  AlternativeSession,
243  Busy,
244  Cancel,
245  ConnectivityError,
246  Decline,
247  Expired,
248  FailedApplication,
249  FailedTransport,
250  GeneralError,
251  Gone,
252  IncompatibleParameters,
253  MediaError,
254  SecurityError,
255  Success,
256  Timeout,
257  UnsupportedApplications,
258  UnsupportedTransports,
259  };
260 
261  Reason();
262 
263  QString text() const;
264  void setText(const QString &text);
265 
266  Type type() const;
267  void setType(Type type);
268 
270  void parse(const QDomElement &element);
271  void toXml(QXmlStreamWriter *writer) const;
273 
274  private:
275  QString m_text;
276  Type m_type;
277  };
278 
279  QXmppJingleIq();
280 
281  Action action() const;
282  void setAction(Action action);
283 
284  QString initiator() const;
285  void setInitiator(const QString &initiator);
286 
287  QString responder() const;
288  void setResponder(const QString &responder);
289 
290  QString sid() const;
291  void setSid(const QString &sid);
292 
294  Content& content() { return m_content; };
295 
297  const Content& content() const { return m_content; };
298 
300  Reason& reason() { return m_reason; };
301 
303  const Reason& reason() const { return m_reason; };
304 
305  // XEP-0167: Jingle RTP Sessions
306  bool ringing() const;
307  void setRinging(bool ringing);
308 
310  static bool isJingleIq(const QDomElement &element);
312 
313 protected:
315  void parseElementFromChild(const QDomElement &element);
316  void toXmlElementFromChild(QXmlStreamWriter *writer) const;
318 
319 private:
320  Action m_action;
321  QString m_initiator;
322  QString m_responder;
323  QString m_sid;
324 
325  Content m_content;
326  Reason m_reason;
327  bool m_ringing;
328 };
329 
330 #endif