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