Commit 8dcd9d32 authored by David Smith's avatar David Smith Committed by david

More changes for groupchat invitations; CS-4034, r=Gato

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10169 b35dd754-fafc-0310-a699-88a17e54d16e
parent e8629f0d
...@@ -37,23 +37,29 @@ public class ClearspaceMUCEventDelegate extends MUCEventDelegate { ...@@ -37,23 +37,29 @@ public class ClearspaceMUCEventDelegate extends MUCEventDelegate {
csComponentAddress = ClearspaceManager.CLEARSPACE_COMPONENT + "." + xmppDomain; csComponentAddress = ClearspaceManager.CLEARSPACE_COMPONENT + "." + xmppDomain;
} }
public InvitationResult sendingInvitation(MUCRoom room, JID userjid) public InvitationResult sendingInvitation(MUCRoom room, JID invitee, JID inviter, String reason)
{ {
// Packet should look like: // Packet should look like:
// <iq to="clearspace.example.org" from="clearspace-conference.example.org"> // <iq to="clearspace.example.org" from="clearspace-conference.example.org">
// <room-invite xmlns="http://jivesoftware.com/clearspace"> // <room-invite xmlns="http://jivesoftware.com/clearspace">
// <user>username@example.org</user> // <inviter>username@example.org</inviter>
// <roomjid>14-1234@clearspace-conference.example.org</roomjid> // <room>14-1234@clearspace-conference.example.org</roomjid>
// <reason>Example Message</reason>
// <invitee>anotheruser@example.org</invitee>
// </room-invite> // </room-invite>
// </iq> // </iq>
IQ query = new IQ(); IQ query = new IQ();
query.setFrom(csMucDomain); query.setFrom(csMucDomain);
Element cmd = query.setChildElement("room-invite", "http://jivesoftware.com/clearspace"); Element cmd = query.setChildElement("room-invite", "http://jivesoftware.com/clearspace");
Element userjidElement = cmd.addElement("userjid"); Element inviterjidElement = cmd.addElement("inviter");
userjidElement.setText(userjid.toBareJID()); inviterjidElement.setText(inviter.toBareJID());
Element roomjidElement = cmd.addElement("roomjid"); Element inviteejidElement = cmd.addElement("invitee");
inviteejidElement.setText(invitee.toBareJID());
Element roomjidElement = cmd.addElement("room");
roomjidElement.setText(room.getJID().toBareJID()); roomjidElement.setText(room.getJID().toBareJID());
Element messageElement = cmd.addElement("reason");
messageElement.setText(reason);
IQ result = ClearspaceManager.getInstance().query(query, 15000); IQ result = ClearspaceManager.getInstance().query(query, 15000);
if (null != result) { if (null != result) {
......
...@@ -39,9 +39,11 @@ public abstract class MUCEventDelegate { ...@@ -39,9 +39,11 @@ public abstract class MUCEventDelegate {
* *
* @param room the MUC room. * @param room the MUC room.
* @param inviteeJID the JID of the user the invitation will be sent to. * @param inviteeJID the JID of the user the invitation will be sent to.
* @param inviterJID the JID of the user that is sending the invitation
* @param inviteMessage the (optional) message that is sent explaining the invitation
* @return true if the user is allowed to join the room. * @return true if the user is allowed to join the room.
*/ */
public abstract InvitationResult sendingInvitation(MUCRoom room, JID inviteeJID); public abstract InvitationResult sendingInvitation(MUCRoom room, JID inviteeJID, JID inviterJID, String inviteMessage);
/** /**
* Returns a map containing room configuration variables and values. * Returns a map containing room configuration variables and values.
......
...@@ -1633,7 +1633,7 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -1633,7 +1633,7 @@ public class LocalMUCRoom implements MUCRoom {
message.setTo(to); message.setTo(to);
if (((MultiUserChatServiceImpl)mucService).getMUCDelegate() != null) { if (((MultiUserChatServiceImpl)mucService).getMUCDelegate() != null) {
switch(((MultiUserChatServiceImpl)mucService).getMUCDelegate().sendingInvitation(this, to)) { switch(((MultiUserChatServiceImpl)mucService).getMUCDelegate().sendingInvitation(this, to, role.getRoleAddress(), reason)) {
case HANDLED_BY_DELEGATE: case HANDLED_BY_DELEGATE:
//if the delegate is taking care of it, there's nothing for us to do //if the delegate is taking care of it, there's nothing for us to do
return; return;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<%@ page import="java.util.Collections" %> <%@ page import="java.util.Collections" %>
<%@ page import="java.util.HashMap" %> <%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %> <%@ page import="java.util.Map" %>
<%@ page import="org.jivesoftware.openfire.muc.CannotBeInvitedException" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
...@@ -91,6 +92,9 @@ ...@@ -91,6 +92,9 @@
catch (NotAllowedException e) { catch (NotAllowedException e) {
errors.put("NotAllowedException","NotAllowedException"); errors.put("NotAllowedException","NotAllowedException");
} }
catch (CannotBeInvitedException e) {
errors.put("CannotBeInvitedException", "CannotBeInvitedExcpetion");
}
} }
} }
...@@ -111,6 +115,9 @@ ...@@ -111,6 +115,9 @@
catch (ConflictException e) { catch (ConflictException e) {
errors.put("ConflictException","ConflictException"); errors.put("ConflictException","ConflictException");
} }
catch (CannotBeInvitedException e) {
errors.put("CannotBeInvitedException", "CannotBeInvitedExcpetion");
}
} }
%> %>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment