~ubuntu-branches/ubuntu/utopic/psi/utopic

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2009-09-25 17:49:51 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090925174951-lvm7kdap82o8xhn3
Tags: 0.13-1
* Updated to upstream version 0.13
* Set Standards-Version to 3.8.3

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 <QPair>
 
24
#include <QString>
 
25
#include <QDomElement>
 
26
 
 
27
class QDomDocument;
 
28
 
 
29
namespace XMPP 
 
30
{
 
31
        class Jid;
 
32
        class Stream;
 
33
 
 
34
        class Stanza
 
35
        {
 
36
        public:
 
37
                enum Kind { Message, Presence, IQ };
 
38
 
 
39
                Stanza();
 
40
                Stanza(const Stanza &from);
 
41
                Stanza & operator=(const Stanza &from);
 
42
                virtual ~Stanza();
 
43
 
 
44
                class Error
 
45
                {
 
46
                public:
 
47
                        enum ErrorType { Cancel = 1, Continue, Modify, Auth, Wait };
 
48
                        enum ErrorCond
 
49
                        {
 
50
                                BadRequest = 1,
 
51
                                Conflict,
 
52
                                FeatureNotImplemented,
 
53
                                Forbidden,
 
54
                                Gone,
 
55
                                InternalServerError,
 
56
                                ItemNotFound,
 
57
                                JidMalformed,
 
58
                                NotAcceptable,
 
59
                                NotAllowed,
 
60
                                NotAuthorized,
 
61
                                PaymentRequired,
 
62
                                RecipientUnavailable,
 
63
                                Redirect,
 
64
                                RegistrationRequired,
 
65
                                RemoteServerNotFound,
 
66
                                RemoteServerTimeout,
 
67
                                ResourceConstraint,
 
68
                                ServiceUnavailable,
 
69
                                SubscriptionRequired,
 
70
                                UndefinedCondition,
 
71
                                UnexpectedRequest
 
72
                        };
 
73
 
 
74
                        Error(int type=Cancel, int condition=UndefinedCondition, const QString &text="", const QDomElement &appSpec=QDomElement());
 
75
 
 
76
                        int type;
 
77
                        int condition;
 
78
                        QString text;
 
79
                        QDomElement appSpec;
 
80
 
 
81
                        int code() const;
 
82
                        bool fromCode(int code);
 
83
 
 
84
                        QPair<QString, QString> description() const;
 
85
 
 
86
                        QDomElement toXml(QDomDocument &doc, const QString &baseNS) const;
 
87
                        bool fromXml(const QDomElement &e, const QString &baseNS);
 
88
                private:
 
89
                        class Private;
 
90
                        int originalCode;
 
91
 
 
92
                };
 
93
 
 
94
                bool isNull() const;
 
95
 
 
96
                QDomElement element() const;
 
97
                QString toString() const;
 
98
 
 
99
                QDomDocument & doc() const;
 
100
                QString baseNS() const;
 
101
                QDomElement createElement(const QString &ns, const QString &tagName);
 
102
                QDomElement createTextElement(const QString &ns, const QString &tagName, const QString &text);
 
103
                void appendChild(const QDomElement &e);
 
104
 
 
105
                Kind kind() const;
 
106
                void setKind(Kind k);
 
107
 
 
108
                Jid to() const;
 
109
                Jid from() const;
 
110
                QString id() const;
 
111
                QString type() const;
 
112
                QString lang() const;
 
113
 
 
114
                void setTo(const Jid &j);
 
115
                void setFrom(const Jid &j);
 
116
                void setId(const QString &id);
 
117
                void setType(const QString &type);
 
118
                void setLang(const QString &lang);
 
119
 
 
120
                Error error() const;
 
121
                void setError(const Error &err);
 
122
                void clearError();
 
123
 
 
124
        private:
 
125
                friend class Stream;
 
126
                Stanza(Stream *s, Kind k, const Jid &to, const QString &type, const QString &id);
 
127
                Stanza(Stream *s, const QDomElement &e);
 
128
 
 
129
                class Private;
 
130
                Private *d;
 
131
        };
 
132
}
 
133
 
 
134
#endif