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