001/** 002 * 003 * Copyright 2003-2007 Jive Software. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.jivesoftware.smack.debugger; 019 020import java.io.*; 021 022import org.jivesoftware.smack.*; 023 024/** 025 * Interface that allows for implementing classes to debug XML traffic. That is a GUI window that 026 * displays XML traffic.<p> 027 * 028 * Every implementation of this interface <b>must</b> have a public constructor with the following 029 * arguments: XMPPConnection, Writer, Reader. 030 * 031 * @author Gaston Dombiak 032 */ 033public interface SmackDebugger { 034 035 /** 036 * Called when a user has logged in to the server. The user could be an anonymous user, this 037 * means that the user would be of the form host/resource instead of the form 038 * user@host/resource. 039 * 040 * @param user the user@host/resource that has just logged in 041 */ 042 public abstract void userHasLogged(String user); 043 044 /** 045 * Returns the special Reader that wraps the main Reader and logs data to the GUI. 046 * 047 * @return the special Reader that wraps the main Reader and logs data to the GUI. 048 */ 049 public abstract Reader getReader(); 050 051 /** 052 * Returns the special Writer that wraps the main Writer and logs data to the GUI. 053 * 054 * @return the special Writer that wraps the main Writer and logs data to the GUI. 055 */ 056 public abstract Writer getWriter(); 057 058 /** 059 * Returns a new special Reader that wraps the new connection Reader. The connection 060 * has been secured so the connection is using a new reader and writer. The debugger 061 * needs to wrap the new reader and writer to keep being notified of the connection 062 * traffic. 063 * 064 * @return a new special Reader that wraps the new connection Reader. 065 */ 066 public abstract Reader newConnectionReader(Reader reader); 067 068 /** 069 * Returns a new special Writer that wraps the new connection Writer. The connection 070 * has been secured so the connection is using a new reader and writer. The debugger 071 * needs to wrap the new reader and writer to keep being notified of the connection 072 * traffic. 073 * 074 * @return a new special Writer that wraps the new connection Writer. 075 */ 076 public abstract Writer newConnectionWriter(Writer writer); 077 078 /** 079 * Returns the thread that will listen for all incoming packets and write them to the GUI. 080 * This is what we call "interpreted" packet data, since it's the packet data as Smack sees 081 * it and not as it's coming in as raw XML. 082 * 083 * @return the PacketListener that will listen for all incoming packets and write them to 084 * the GUI 085 */ 086 public abstract PacketListener getReaderListener(); 087 088 /** 089 * Returns the thread that will listen for all outgoing packets and write them to the GUI. 090 * 091 * @return the PacketListener that will listen for all sent packets and write them to 092 * the GUI 093 */ 094 public abstract PacketListener getWriterListener(); 095}