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.Reader; 021import java.io.Writer; 022 023import org.jivesoftware.smack.StanzaListener; 024 025/** 026 * Interface that allows for implementing classes to debug XML traffic. That is a GUI window that 027 * displays XML traffic.<p> 028 * 029 * Every implementation of this interface <b>must</b> have a public constructor with the following 030 * arguments: XMPPConnection, Writer, Reader. 031 * 032 * @author Gaston Dombiak 033 */ 034public interface SmackDebugger { 035 036 /** 037 * Called when a user has logged in to the server. The user could be an anonymous user, this 038 * means that the user would be of the form host/resource instead of the form 039 * user@host/resource. 040 * 041 * @param user the user@host/resource that has just logged in 042 */ 043 public abstract void userHasLogged(String user); 044 045 /** 046 * Returns the special Reader that wraps the main Reader and logs data to the GUI. 047 * 048 * @return the special Reader that wraps the main Reader and logs data to the GUI. 049 */ 050 public abstract Reader getReader(); 051 052 /** 053 * Returns the special Writer that wraps the main Writer and logs data to the GUI. 054 * 055 * @return the special Writer that wraps the main Writer and logs data to the GUI. 056 */ 057 public abstract Writer getWriter(); 058 059 /** 060 * Returns a new special Reader that wraps the new connection Reader. The connection 061 * has been secured so the connection is using a new reader and writer. The debugger 062 * needs to wrap the new reader and writer to keep being notified of the connection 063 * traffic. 064 * 065 * @return a new special Reader that wraps the new connection Reader. 066 */ 067 public abstract Reader newConnectionReader(Reader reader); 068 069 /** 070 * Returns a new special Writer that wraps the new connection Writer. The connection 071 * has been secured so the connection is using a new reader and writer. The debugger 072 * needs to wrap the new reader and writer to keep being notified of the connection 073 * traffic. 074 * 075 * @return a new special Writer that wraps the new connection Writer. 076 */ 077 public abstract Writer newConnectionWriter(Writer writer); 078 079 /** 080 * Returns the thread that will listen for all incoming packets and write them to the GUI. 081 * This is what we call "interpreted" stanza(/packet) data, since it's the stanza(/packet) data as Smack sees 082 * it and not as it's coming in as raw XML. 083 * 084 * @return the PacketListener that will listen for all incoming packets and write them to 085 * the GUI 086 */ 087 public abstract StanzaListener getReaderListener(); 088 089 /** 090 * Returns the thread that will listen for all outgoing packets and write them to the GUI. 091 * 092 * @return the PacketListener that will listen for all sent packets and write them to 093 * the GUI 094 */ 095 public abstract StanzaListener getWriterListener(); 096}