summaryrefslogtreecommitdiffstats
blob: 966f23573b1eb1066c988f6621aecea98e42df6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
 * Copyright (c) 2012, Isode Limited, London, England.
 * All rights reserved.
 */
/*
 * Copyright (c) 2010, Kevin Smith
 * All rights reserved.
 */
package com.isode.stroke.elements;

import java.util.Vector;
import com.isode.stroke.jid.JID;

/**
 * Class representing a MUC User Payload
 *
 */
public class MUCUserPayload extends Payload {
    public static class StatusCode {
        public int code;
        public StatusCode()  {
            code = 0;
        }
        public StatusCode(int code) {
            this.code = code;
        }
    };

    /**
     * Class representing an Invite stanza.
     * Reason is optional while "from" and "to" are mutually exclusive.
     * "From" is used for MUC sending to invited client and is the JID 
     * the MUC claims the invite is from.
     * "To" is used sending to MUC from inviting client and is the 
     * JID to send the invite to.
     */
    public static class Invite {
        public JID from;
        public String reason;
        public JID to;
    };

    public Invite invite_;

    public String password_;

    public Payload payload_;

    public Vector<StatusCode> statusCodes_ = new Vector<StatusCode>();

    private Vector<MUCItem> items_ = new Vector<MUCItem>();

    /**
     * Constructor 
     */
    public MUCUserPayload() {
    }

    /**
     * Add a MUC Item
     * @param item item to be added, not null
     */
    public void addItem(MUCItem item) {
        items_.add(item);
    }

    /**
     * Add status code
     * @param code status code, not null
     */
    public void addStatusCode(StatusCode code) {
        statusCodes_.add(code);
    }

    /**
     * Get the invite object
     * @return invite object, null if not set
     */
    public Invite getInvite() {
        return invite_;
    }

    /**
     * Get the list of MUC items
     * @return list of MUC Items, can be empty but not null
     */
    public Vector<MUCItem> getItems() {
        return items_;
    }

    /**
     * Get the password for the room
     * @return room password, can be null
     */
    public String getPassword() {
        return password_;
    }

    /**
     * Get the payload
     * @return payload, null if not set
     */
    public Payload getPayload() {
        return payload_;
    }
    
    /**
     * Get the list of status codes
     * @return list of status codes, can be empty but not null
     */
    public Vector<StatusCode> getStatusCodes() {
        return statusCodes_;
    }
    
    /**
     * Set the invite value
     * @param invite invite value, not null
     */
    public void setInvite(Invite invite) {
        invite_ = invite;
    }
    
    /**
     * Set the password for the MUC
     * @param password password, can be null
     */
    public void setPassword(String password) {
        password_ = password;
    }
    
    /**
     * Set the payload
     * @param p payload, not null
     */
    public void setPayload(Payload p) {
        payload_ = p;
    }
}