~ubuntu-branches/ubuntu/raring/ksirk/raring-proposed

« back to all changes in this revision

Viewing changes to ksirk/iris/src/xmpp/xmpp-core/xmpp_stanza.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-12-07 18:07:17 UTC
  • Revision ID: package-import@ubuntu.com-20121207180717-sj8ituy2axxw3b2s
Tags: upstream-4.9.90
ImportĀ upstreamĀ versionĀ 4.9.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2003  Justin Karneges
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2.1 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this library; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 *
 
18
 */
 
19
 
 
20
#ifndef XMPP_STANZA_H
 
21
#define XMPP_STANZA_H
 
22
 
 
23
#include "iris_export.h"
 
24
#include <QPair>
 
25
#include <QString>
 
26
#include <QDomElement>
 
27
 
 
28
class QDomDocument;
 
29
 
 
30
namespace XMPP 
 
31
{
 
32
        class Jid;
 
33
        class Stream;
 
34
 
 
35
        class IRIS_EXPORT Stanza
 
36
        {
 
37
        public:
 
38
                enum Kind { Message, Presence, IQ };
 
39
 
 
40
                Stanza();
 
41
                Stanza(const Stanza &from);
 
42
                Stanza & operator=(const Stanza &from);
 
43
                virtual ~Stanza();
 
44
 
 
45
                class Error
 
46
                {
 
47
                public:
 
48
                        enum ErrorType { Cancel = 1, Continue, Modify, Auth, Wait };
 
49
                        enum ErrorCond
 
50
                        {
 
51
                                BadRequest = 1,
 
52
                                Conflict,
 
53
                                FeatureNotImplemented,
 
54
                                Forbidden,
 
55
                                Gone,
 
56
                                InternalServerError,
 
57
                                ItemNotFound,
 
58
                                JidMalformed,
 
59
                                NotAcceptable,
 
60
                                NotAllowed,
 
61
                                NotAuthorized,
 
62
                                PaymentRequired,
 
63
                                RecipientUnavailable,
 
64
                                Redirect,
 
65
                                RegistrationRequired,
 
66
                                RemoteServerNotFound,
 
67
                                RemoteServerTimeout,
 
68
                                ResourceConstraint,
 
69
                                ServiceUnavailable,
 
70
                                SubscriptionRequired,
 
71
                                UndefinedCondition,
 
72
                                UnexpectedRequest
 
73
                        };
 
74
 
 
75
                        Error(int type=Cancel, int condition=UndefinedCondition, const QString &text="", const QDomElement &appSpec=QDomElement());
 
76
 
 
77
                        int type;
 
78
                        int condition;
 
79
                        QString text;
 
80
                        QDomElement appSpec;
 
81
 
 
82
                        int code() const;
 
83
                        bool fromCode(int code);
 
84
 
 
85
                        QPair<QString, QString> description() const;
 
86
 
 
87
                        QDomElement toXml(QDomDocument &doc, const QString &baseNS) const;
 
88
                        bool fromXml(const QDomElement &e, const QString &baseNS);
 
89
                private:
 
90
                        class Private;
 
91
                        int originalCode;
 
92
 
 
93
                };
 
94
 
 
95
                bool isNull() const;
 
96
 
 
97
                QDomElement element() const;
 
98
                QString toString() const;
 
99
 
 
100
                QDomDocument & doc() const;
 
101
                QString baseNS() const;
 
102
                QDomElement createElement(const QString &ns, const QString &tagName);
 
103
                QDomElement createTextElement(const QString &ns, const QString &tagName, const QString &text);
 
104
                void appendChild(const QDomElement &e);
 
105
 
 
106
                Kind kind() const;
 
107
                void setKind(Kind k);
 
108
 
 
109
                Jid to() const;
 
110
                Jid from() const;
 
111
                QString id() const;
 
112
                QString type() const;
 
113
                QString lang() const;
 
114
 
 
115
                void setTo(const Jid &j);
 
116
                void setFrom(const Jid &j);
 
117
                void setId(const QString &id);
 
118
                void setType(const QString &type);
 
119
                void setLang(const QString &lang);
 
120
 
 
121
                Error error() const;
 
122
                void setError(const Error &err);
 
123
                void clearError();
 
124
 
 
125
        private:
 
126
                friend class Stream;
 
127
                Stanza(Stream *s, Kind k, const Jid &to, const QString &type, const QString &id);
 
128
                Stanza(Stream *s, const QDomElement &e);
 
129
 
 
130
                class Private;
 
131
                Private *d;
 
132
        };
 
133
}
 
134
 
 
135
#endif