QXmppJingleIq.h

    00001 /*
    00002  * Copyright (C) 2008-2011 The QXmpp developers
    00003  *
    00004  * Author:
    00005  *  Jeremy Lainé
    00006  *
    00007  * Source:
    00008  *  http://code.google.com/p/qxmpp
    00009  *
    00010  * This file is a part of QXmpp library.
    00011  *
    00012  * This library is free software; you can redistribute it and/or
    00013  * modify it under the terms of the GNU Lesser General Public
    00014  * License as published by the Free Software Foundation; either
    00015  * version 2.1 of the License, or (at your option) any later version.
    00016  *
    00017  * This library is distributed in the hope that it will be useful,
    00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00020  * Lesser General Public License for more details.
    00021  *
    00022  */
    00023
    00024 #ifndef QXMPPJINGLEIQ_H
    00025 #define QXMPPJINGLEIQ_H
    00026
    00027 #include <QHostAddress>
    00028
    00029 #include "QXmppIq.h"
    00030
    00034
    00035 class QXmppJinglePayloadType
    00036 {
    00037 public:
    00038     QXmppJinglePayloadType();
    00039
    00040     unsigned char channels() const;
    00041     void setChannels(unsigned char channels);
    00042
    00043     unsigned int clockrate() const;
    00044     void setClockrate(unsigned int clockrate);
    00045
    00046     unsigned char id() const;
    00047     void setId(unsigned char id);
    00048
    00049     unsigned int maxptime() const;
    00050     void setMaxptime(unsigned int maxptime);
    00051
    00052     QString name() const;
    00053     void setName(const QString &name);
    00054
    00055     QMap<QString, QString> parameters() const;
    00056     void setParameters(const QMap<QString, QString> &parameters);
    00057
    00058     unsigned int ptime() const;
    00059     void setPtime(unsigned int ptime);
    00060
    00062     void parse(const QDomElement &element);
    00063     void toXml(QXmlStreamWriter *writer) const;
    00065
    00066     bool operator==(const QXmppJinglePayloadType &other) const;
    00067
    00068 private:
    00069     unsigned char m_channels;
    00070     unsigned int m_clockrate;
    00071     unsigned char m_id;
    00072     unsigned int m_maxptime;
    00073     QString m_name;
    00074     QMap<QString, QString> m_parameters;
    00075     unsigned int m_ptime;
    00076 };
    00077
    00081
    00082 class QXmppJingleCandidate
    00083 {
    00084 public:
    00086     enum Type
    00087     {
    00088         HostType,
    00089         PeerReflexiveType,
    00090
    00091         ServerReflexiveType,
    00092
    00093         RelayedType,
    00094
    00095     };
    00096
    00097     QXmppJingleCandidate();
    00098
    00099     int component() const;
    00100     void setComponent(int component);
    00101
    00102     int foundation() const;
    00103     void setFoundation(int foundation);
    00104
    00105     QHostAddress host() const;
    00106     void setHost(const QHostAddress &host);
    00107
    00108     QString id() const;
    00109     void setId(const QString &id);
    00110
    00111     int network() const;
    00112     void setNetwork(int network);
    00113
    00114     quint16 port() const;
    00115     void setPort(quint16 port);
    00116
    00117     int priority() const;
    00118     void setPriority(int priority);
    00119
    00120     QString protocol() const;
    00121     void setProtocol(const QString &protocol);
    00122
    00123     QXmppJingleCandidate::Type type() const;
    00124     void setType(QXmppJingleCandidate::Type);
    00125
    00126     bool isNull() const;
    00127
    00128     static QXmppJingleCandidate::Type typeFromString(const QString &typeStr, bool *ok = 0);
    00129     static QString typeToString(QXmppJingleCandidate::Type type);
    00130
    00132     void parse(const QDomElement &element);
    00133     void toXml(QXmlStreamWriter *writer) const;
    00135
    00136 private:
    00137     int m_component;
    00138     int m_foundation;
    00139     int m_generation;
    00140     QHostAddress m_host;
    00141     QString m_id;
    00142     int m_network;
    00143     quint16 m_port;
    00144     QString m_protocol;
    00145     int m_priority;
    00146     QXmppJingleCandidate::Type m_type;
    00147 };
    00148
    00153
    00154 class QXmppJingleIq : public QXmppIq
    00155 {
    00156 public:
    00158     enum Action {
    00159         ContentAccept,
    00160         ContentAdd,
    00161         ContentModify,
    00162         ContentReject,
    00163         ContentRemove,
    00164         DescriptionInfo,
    00165         SecurityInfo,
    00166         SessionAccept,
    00167         SessionInfo,
    00168         SessionInitiate,
    00169         SessionTerminate,
    00170         TransportAccept,
    00171         TransportInfo,
    00172         TransportReject,
    00173         TransportReplace,
    00174     };
    00175
    00180
    00181     class Content
    00182     {
    00183     public:
    00184         Content();
    00185
    00186         QString creator() const;
    00187         void setCreator(const QString &creator);
    00188
    00189         QString name() const;
    00190         void setName(const QString &name);
    00191
    00192         QString senders() const;
    00193         void setSenders(const QString &senders);
    00194
    00195         // XEP-0167: Jingle RTP Sessions
    00196         QString descriptionMedia() const;
    00197         void setDescriptionMedia(const QString &media);
    00198
    00199         void addPayloadType(const QXmppJinglePayloadType &payload);
    00200         QList<QXmppJinglePayloadType> payloadTypes() const;
    00201         void setPayloadTypes(const QList<QXmppJinglePayloadType> &payloadTypes);
    00202
    00203         void addTransportCandidate(const QXmppJingleCandidate &candidate);
    00204         QList<QXmppJingleCandidate> transportCandidates() const;
    00205
    00206         QString transportUser() const;
    00207         void setTransportUser(const QString &user);
    00208
    00209         QString transportPassword() const;
    00210         void setTransportPassword(const QString &password);
    00211
    00213         void parse(const QDomElement &element);
    00214         void toXml(QXmlStreamWriter *writer) const;
    00216
    00217     private:
    00218         QString m_creator;
    00219         QString m_disposition;
    00220         QString m_name;
    00221         QString m_senders;
    00222
    00223         QString m_descriptionMedia;
    00224         QString m_descriptionType;
    00225         QString m_transportType;
    00226         QString m_transportUser;
    00227         QString m_transportPassword;
    00228         QList<QXmppJinglePayloadType> m_payloadTypes;
    00229         QList<QXmppJingleCandidate> m_transportCandidates;
    00230     };
    00231
    00236
    00237     class Reason
    00238     {
    00239     public:
    00240         enum Type {
    00241             None,
    00242             AlternativeSession,
    00243             Busy,
    00244             Cancel,
    00245             ConnectivityError,
    00246             Decline,
    00247             Expired,
    00248             FailedApplication,
    00249             FailedTransport,
    00250             GeneralError,
    00251             Gone,
    00252             IncompatibleParameters,
    00253             MediaError,
    00254             SecurityError,
    00255             Success,
    00256             Timeout,
    00257             UnsupportedApplications,
    00258             UnsupportedTransports,
    00259         };
    00260
    00261         Reason();
    00262
    00263         QString text() const;
    00264         void setText(const QString &text);
    00265
    00266         Type type() const;
    00267         void setType(Type type);
    00268
    00270         void parse(const QDomElement &element);
    00271         void toXml(QXmlStreamWriter *writer) const;
    00273
    00274     private:
    00275         QString m_text;
    00276         Type m_type;
    00277     };
    00278
    00279     QXmppJingleIq();
    00280
    00281     Action action() const;
    00282     void setAction(Action action);
    00283
    00284     QString initiator() const;
    00285     void setInitiator(const QString &initiator);
    00286
    00287     QString responder() const;
    00288     void setResponder(const QString &responder);
    00289
    00290     QString sid() const;
    00291     void setSid(const QString &sid);
    00292
    00294     Content& content() { return m_content; };
    00295
    00297     const Content& content() const { return m_content; };
    00298
    00300     Reason& reason() { return m_reason; };
    00301
    00303     const Reason& reason() const { return m_reason; };
    00304
    00305     // XEP-0167: Jingle RTP Sessions
    00306     bool ringing() const;
    00307     void setRinging(bool ringing);
    00308
    00310     static bool isJingleIq(const QDomElement &element);
    00312
    00313 protected:
    00315     void parseElementFromChild(const QDomElement &element);
    00316     void toXmlElementFromChild(QXmlStreamWriter *writer) const;
    00318
    00319 private:
    00320     Action m_action;
    00321     QString m_initiator;
    00322     QString m_responder;
    00323     QString m_sid;
    00324
    00325     Content m_content;
    00326     Reason m_reason;
    00327     bool m_ringing;
    00328 };
    00329
    00330 #endif

All Classes Functions Enumerations Enumerator Properties