~ubuntu-branches/ubuntu/trusty/jreen/trusty

« back to all changes in this revision

Viewing changes to src/mucroom_p.h

  • Committer: Package Import Robot
  • Author(s): Prasad Murthy
  • Date: 2013-03-08 00:00:33 UTC
  • Revision ID: package-import@ubuntu.com-20130308000033-x8thp6syo1kkh63s
Tags: upstream-1.1.1
Import upstream version 1.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Jreen
 
4
**
 
5
** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru>
 
6
** Copyright © 2011 Aleksey Sidorov <gorthauer87@yandex.ru>
 
7
**
 
8
*****************************************************************************
 
9
**
 
10
** $JREEN_BEGIN_LICENSE$
 
11
** This program is free software: you can redistribute it and/or modify
 
12
** it under the terms of the GNU General Public License as published by
 
13
** the Free Software Foundation, either version 2 of the License, or
 
14
** (at your option) any later version.
 
15
**
 
16
** This program is distributed in the hope that it will be useful,
 
17
** but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
19
** See the GNU General Public License for more details.
 
20
**
 
21
** You should have received a copy of the GNU General Public License
 
22
** along with this program.  If not, see http://www.gnu.org/licenses/.
 
23
** $JREEN_END_LICENSE$
 
24
**
 
25
****************************************************************************/
 
26
 
 
27
#ifndef MUCROOM_P_H
 
28
#define MUCROOM_P_H
 
29
 
 
30
#include "mucroom.h"
 
31
#include "mucmessagesession_p.h"
 
32
#include "client_p.h"
 
33
 
 
34
namespace Jreen
 
35
{
 
36
class MUCRoomUserQuery;
 
37
 
 
38
class MUCRoomPrivate
 
39
{
 
40
public:
 
41
        Q_DECLARE_PUBLIC(MUCRoom)
 
42
 
 
43
        MUCRoomPrivate(MUCRoom *room) :
 
44
                q_ptr(room), client(0), affiliation(MUCRoom::AffiliationOutcast),
 
45
                role(MUCRoom::RoleNone), maxChars(-1), maxStanzas(-1), seconds(-1),
 
46
                currentPresence(Presence::Unavailable, JID(), QString()), isJoined(false),
 
47
            startedJoining(false)
 
48
        {
 
49
        }
 
50
 
 
51
        static MUCRoomPrivate *get(MUCRoom *room) { return room->d_func(); }
 
52
        void handlePresence(const Presence &pres);
 
53
        void handleMessage(const Message &msg);
 
54
 
 
55
        MUCRoom *q_ptr;
 
56
        QPointer<Client> client;
 
57
        JID jid;
 
58
        MUCRoom::Affiliation affiliation;
 
59
        MUCRoom::Role role;
 
60
        QHash<QString, QSharedPointer<MUCRoomUserQuery> > participantsHash;
 
61
        QString password;
 
62
        int maxChars;
 
63
        int maxStanzas;
 
64
        int seconds;
 
65
        Presence currentPresence;
 
66
        bool isJoined;
 
67
        bool startedJoining;
 
68
        QDateTime since;
 
69
        MUCMessageSession *session;
 
70
        QString subject;
 
71
};
 
72
 
 
73
class MUCRoomQuery : public Payload
 
74
{
 
75
        J_PAYLOAD(Jreen::MUCRoomQuery)
 
76
        public:
 
77
                MUCRoomQuery(const QString &password)
 
78
          : m_password(password), m_maxChars(-1), m_maxStanzas(-1), m_seconds(-1) {}
 
79
        void setMaxChars(int maxChars) { m_maxChars = qMax(-1, maxChars); }
 
80
        void setMaxStanzas(int maxStanzas) { m_maxStanzas = qMax(-1, maxStanzas); }
 
81
        void setSeconds(int seconds) { m_seconds = qMax(-1, seconds); }
 
82
        void setSince(const QDateTime &since) { m_since = since; }
 
83
private:
 
84
        QString m_password;
 
85
        int m_maxChars;
 
86
        int m_maxStanzas;
 
87
        int m_seconds;
 
88
        QDateTime m_since;
 
89
        friend class JREEN_AUTOTEST_EXPORT MUCRoomQueryFactory;
 
90
};
 
91
 
 
92
class MUCRoomItem
 
93
{
 
94
public:
 
95
        MUCRoomItem() : affiliation(MUCRoom::AffiliationInvalid), role(MUCRoom::RoleInvalid) {}
 
96
 
 
97
        MUCRoom::Affiliation affiliation;
 
98
        MUCRoom::Role role;
 
99
        JID jid;
 
100
        QString reason;
 
101
        JID actor;
 
102
        QString nick;
 
103
};
 
104
 
 
105
class MUCRoomUserQuery : public Payload
 
106
{
 
107
        J_PAYLOAD(Jreen::MUCRoomUserQuery)
 
108
public:
 
109
        enum Flag
 
110
        {
 
111
                NonAnonymous         = 0x0001,
 
112
                SemiAnonymous        = 0x0002,
 
113
                FullyAnonymous       = 0x0004,
 
114
                AffiliationChangeWNR = 0x0008,
 
115
                Self                 = 0x0010,
 
116
                LoggingEnabled       = 0x0020,
 
117
                LoggingDisabled      = 0x0040,
 
118
                NewRoom              = 0x0080,
 
119
                NickAssigned         = 0x0100,
 
120
                Banned               = 0x0200,
 
121
                NickChanged          = 0x0400,
 
122
                Kicked               = 0x0800,
 
123
                AffiliationChanged   = 0x1000,
 
124
                MembershipRequired   = 0x2000,
 
125
                RoomSegfaulted       = 0x4000
 
126
        };
 
127
        enum Operation
 
128
        {
 
129
                Invite = 1,
 
130
                Decline = 2
 
131
        };
 
132
        
 
133
        MUCRoomUserQuery() : flags(0), operation(0)
 
134
        {
 
135
        }
 
136
        
 
137
        MUCRoomUserQuery(Operation op, const JID &to, const QString &reason, const QString &thread)
 
138
            : flags(0), operation(op), thread(thread)
 
139
        {
 
140
                item.jid = to;
 
141
                item.reason = reason;
 
142
        }
 
143
 
 
144
        MUCRoomItem item;
 
145
        JID alternate;
 
146
        int flags : 24;
 
147
        int operation : 8;
 
148
        QString status;
 
149
        QString password;
 
150
        QString thread;
 
151
};
 
152
 
 
153
class MUCRoomAdminQuery : public Payload
 
154
{
 
155
        J_PAYLOAD(Jreen::MUCRoomAdminQuery)
 
156
        public:
 
157
        MUCRoomAdminQuery() {}
 
158
        MUCRoomAdminQuery(MUCRoom::Affiliation a)
 
159
        {
 
160
                MUCRoomItem item;
 
161
                item.affiliation = a;
 
162
                items << item;
 
163
        }
 
164
        MUCRoomAdminQuery(const JID &jid, MUCRoom::Affiliation a, const QString &reason)
 
165
        {
 
166
                MUCRoomItem item;
 
167
                item.affiliation = a;
 
168
                item.jid = jid;
 
169
                item.reason = reason;
 
170
                items << item;
 
171
        }
 
172
        MUCRoomAdminQuery(const QString &nick, MUCRoom::Affiliation a, const QString &reason)
 
173
        {
 
174
                MUCRoomItem item;
 
175
                item.affiliation = a;
 
176
                item.nick = nick;
 
177
                item.reason = reason;
 
178
                items << item;
 
179
        }
 
180
        MUCRoomAdminQuery(const QString &nick, MUCRoom::Role r, const QString &reason)
 
181
        {
 
182
                MUCRoomItem item;
 
183
                item.role = r;
 
184
                item.nick = nick;
 
185
                item.reason = reason;
 
186
                items << item;
 
187
        }
 
188
        QList<MUCRoomItem> items;
 
189
};
 
190
 
 
191
class MUCRoomOwnerQuery : public Payload
 
192
{
 
193
        J_PAYLOAD(Jreen::MUCRoomOwnerQuery)
 
194
        public:
 
195
                MUCRoomOwnerQuery() {}
 
196
        MUCRoomOwnerQuery(const DataForm::Ptr &f) : form(f) {}
 
197
        DataForm::Ptr form;
 
198
};
 
199
}
 
200
 
 
201
#endif // MUCROOM_P_H