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.provider.IQProvider; 23 import org.jivesoftware.smack.packet.IQ; 24 import org.jivesoftware.smack.packet.Packet; 25 import org.jivesoftware.smack.util.PacketParserUtils; 26 import org.xmlpull.v1.XmlPullParser; 27 28 import java.util.ArrayList; 29 import java.util.List; 30 31 /** 32 * An IQProvider for transcripts. 33 * 34 * @author Gaston Dombiak 35 */ 36 public class TranscriptProvider implements IQProvider { 37 38 public TranscriptProvider() { 39 super(); 40 } 41 42 public IQ parseIQ(XmlPullParser parser) throws Exception { 43 String sessionID = parser.getAttributeValue("", "sessionID"); 44 List<Packet> packets = new ArrayList<Packet>(); 45 46 boolean done = false; 47 while (!done) { 48 int eventType = parser.next(); 49 if (eventType == XmlPullParser.START_TAG) { 50 if (parser.getName().equals("message")) { 51 packets.add(PacketParserUtils.parseMessage(parser)); 52 } 53 else if (parser.getName().equals("presence")) { 54 packets.add(PacketParserUtils.parsePresence(parser)); 55 } 56 } 57 else if (eventType == XmlPullParser.END_TAG) { 58 if (parser.getName().equals("transcript")) { 59 done = true; 60 } 61 } 62 } 63 64 return new Transcript(sessionID, packets); 65 } 66 } 67