1 /** 2 * $Revision$ 3 * $Date$ 4 * 5 * Copyright 2003-2007 Jive Software. 6 * 7 * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 package org.jivesoftware.smackx.workgroup.packet; 21 22 import org.jivesoftware.smack.packet.IQ; 23 24 /** 25 * A IQ packet used to depart a workgroup queue. There are two cases for issuing a depart 26 * queue request:<ul> 27 * <li>The user wants to leave the queue. In this case, an instance of this class 28 * should be created without passing in a user address. 29 * <li>An administrator or the server removes wants to remove a user from the queue. 30 * In that case, the address of the user to remove from the queue should be 31 * used to create an instance of this class.</ul> 32 * 33 * @author loki der quaeler 34 */ 35 public class DepartQueuePacket extends IQ { 36 37 private String user; 38 39 /** 40 * Creates a depart queue request packet to the specified workgroup. 41 * 42 * @param workgroup the workgroup to depart. 43 */ DepartQueuePacket(String workgroup)44 public DepartQueuePacket(String workgroup) { 45 this(workgroup, null); 46 } 47 48 /** 49 * Creates a depart queue request to the specified workgroup and for the 50 * specified user. 51 * 52 * @param workgroup the workgroup to depart. 53 * @param user the user to make depart from the queue. 54 */ DepartQueuePacket(String workgroup, String user)55 public DepartQueuePacket(String workgroup, String user) { 56 this.user = user; 57 58 setTo(workgroup); 59 setType(IQ.Type.SET); 60 setFrom(user); 61 } 62 getChildElementXML()63 public String getChildElementXML() { 64 StringBuilder buf = new StringBuilder("<depart-queue xmlns=\"http://jabber.org/protocol/workgroup\""); 65 66 if (this.user != null) { 67 buf.append("><jid>").append(this.user).append("</jid></depart-queue>"); 68 } 69 else { 70 buf.append("/>"); 71 } 72 73 return buf.toString(); 74 } 75 }