01: /**
02: * Copyright (C) 2004-2007 Jive Software. All rights reserved.
03: *
04: * This software is published under the terms of the GNU Public License (GPL),
05: * a copy of which is included in this distribution.
06: */package org.xmpp.muc;
07:
08: import org.dom4j.Element;
09: import org.xmpp.packet.Message;
10:
11: /**
12: * Represents an invitation to a Multi-User Chat room from a room occupant to a user that is not
13: * an occupant of the room. The invitation must be <b>sent to the room</b> and it's the room
14: * responsibility to forward the invitation to the invitee. The <b>sender of the invitation must be
15: * the real full JID of the inviter</b>.<p>
16: *
17: * Code example:
18: * <pre>
19: * // Invite the someone to the room.
20: * Invitation invitation = new Invitation("invitee@jabber.org", "Join this excellent room");
21: * invitation.setTo("room@conference.jabber.org");
22: * invitation.setFrom("inviter@jabber.org/notebook");
23: *
24: * component.sendPacket(invitation);
25: * </pre>
26: *
27: * @author Gaston Dombiak
28: */
29: public class Invitation extends Message {
30:
31: /**
32: * Creates a new invitation.
33: *
34: * @param invitee the XMPP address of the invitee. The room will forward the invitation to this
35: * address.
36: * @param reason the reason why the invitation is being sent.
37: */
38: public Invitation(String invitee, String reason) {
39: super ();
40: Element element = addChildElement("x",
41: "http://jabber.org/protocol/muc#user");
42: Element invite = element.addElement("invite");
43: invite.addAttribute("to", invitee);
44: if (reason != null && reason.length() > 0) {
45: invite.addElement("reason").setText(reason);
46: }
47: }
48: }
|