mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 22:32:06 +01:00
Remove MUC DeafOccupantIntercepter
as it's a old (likely unused) Jive (Wildfire) proprietary extension.
This commit is contained in:
parent
328b733f7e
commit
36744ea0d1
2 changed files with 0 additions and 120 deletions
|
@ -1772,53 +1772,6 @@ public class MultiUserChatTest extends SmackTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that deaf occupants do not get broadcasted messages. Deaf occupants is a Jive
|
||||
* extension to MUC so it may not work with other servers.
|
||||
*/
|
||||
public void testDeafOccupants() {
|
||||
try {
|
||||
// User2 joins the room as a "normal" occupant
|
||||
MultiUserChat muc2 = new MultiUserChat(getConnection(1), room);
|
||||
muc2.join("testbot2");
|
||||
|
||||
// User3 joins the room as a "deaf" occupant
|
||||
MultiUserChat muc3 = new MultiUserChat(getConnection(2), room);
|
||||
muc3.addPresenceInterceptor(new DeafOccupantInterceptor());
|
||||
muc3.join("testbot3");
|
||||
|
||||
// User1 sends some messages to the room
|
||||
muc.sendMessage("Message 1");
|
||||
muc.sendMessage("Message 2");
|
||||
|
||||
Thread.sleep(500);
|
||||
|
||||
Message msg;
|
||||
// Normal occupant gets first message
|
||||
msg = muc2.nextMessage(1000);
|
||||
assertNotNull("First message is null", msg);
|
||||
// Get second message
|
||||
msg = muc2.nextMessage(1000);
|
||||
assertNotNull("Second message is null", msg);
|
||||
// Try to get a third message
|
||||
msg = muc2.nextMessage(1000);
|
||||
assertNull("Third message is not null", msg);
|
||||
|
||||
// Deaf occupant tries to get a third message
|
||||
msg = muc3.nextMessage(1000);
|
||||
assertNull("Deaf occupant got a broadcast message", msg);
|
||||
|
||||
// User2 leaves the room
|
||||
muc2.leave();
|
||||
// User3 leaves the room
|
||||
muc3.leave();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void makeRoomModerated() throws XMPPException {
|
||||
// User1 (which is the room owner) converts the instant room into a moderated room
|
||||
Form form = muc.getConfigurationForm();
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2006 Jive Software.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smackx.muc;
|
||||
|
||||
import org.jivesoftware.smack.PacketInterceptor;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
|
||||
/**
|
||||
* Packet interceptor that will intercept presence packets sent to the MUC service to indicate
|
||||
* that the user wants to be a deaf occupant. A user can only indicate that he wants to be a
|
||||
* deaf occupant while joining the room. It is not possible to become deaf or stop being deaf
|
||||
* after the user joined the room.<p>
|
||||
*
|
||||
* Deaf occupants will not get messages broadcasted to all room occupants. However, they will
|
||||
* be able to get private messages, presences, IQ packets or room history. To use this
|
||||
* functionality you will need to send the message
|
||||
* {@link MultiUserChat#addPresenceInterceptor(org.jivesoftware.smack.PacketInterceptor)} and
|
||||
* pass this interceptor as the parameter.<p>
|
||||
*
|
||||
* Note that this is a custom extension to the MUC service so it may not work with other servers
|
||||
* than Wildfire.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class DeafOccupantInterceptor implements PacketInterceptor {
|
||||
|
||||
public void interceptPacket(Packet packet) {
|
||||
Presence presence = (Presence) packet;
|
||||
// Check if user is joining a room
|
||||
if (Presence.Type.available == presence.getType() &&
|
||||
presence.getExtension("x", "http://jabber.org/protocol/muc") != null) {
|
||||
// Add extension that indicates that user wants to be a deaf occupant
|
||||
packet.addExtension(new DeafExtension());
|
||||
}
|
||||
}
|
||||
|
||||
private static class DeafExtension implements PacketExtension {
|
||||
|
||||
public String getElementName() {
|
||||
return "x";
|
||||
}
|
||||
|
||||
public String getNamespace() {
|
||||
return "http://jivesoftware.org/protocol/muc";
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace())
|
||||
.append("\">");
|
||||
buf.append("<deaf-occupant/>");
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue