001/**
002 *
003 * Copyright the original author or authors
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 */
017package org.jivesoftware.smackx.jingle;
018
019import java.util.logging.Logger;
020
021import org.jivesoftware.smack.packet.IQ;
022import org.jivesoftware.smackx.jingle.packet.Jingle;
023import org.jivesoftware.smackx.jingle.packet.JingleError;
024
025/**
026 *  @author Jeff Williams
027 *  @see JingleSessionState
028 */
029public class JingleSessionStateEnded extends JingleSessionState {
030        
031        private static final Logger LOGGER = Logger.getLogger(JingleSessionStateEnded.class.getName());
032
033        private static JingleSessionStateEnded INSTANCE = null;
034
035    protected JingleSessionStateEnded() {
036        // Prevent instantiation of the class.
037    }
038
039    /**
040     *  A thread-safe means of getting the one instance of this class.
041     *  @return The singleton instance of this class.
042     */
043    public synchronized static JingleSessionState getInstance() {
044        if (INSTANCE == null) {
045            INSTANCE = new JingleSessionStateEnded();
046        }
047
048        return INSTANCE;
049    }
050
051    public void enter() {
052        LOGGER.fine("Session Ended");
053        LOGGER.fine("-------------------------------------------------------------------");
054
055    }
056
057    public void exit() {
058        // TODO Auto-generated method stub
059
060    }
061
062    /**
063     * Pretty much nothing is valid for receiving once we've ended the session.
064     */
065    public IQ processJingle(JingleSession session, Jingle jingle, JingleActionEnum action) {
066        IQ response = null;
067        
068        response = session.createJingleError(jingle, JingleError.MALFORMED_STANZA);
069
070        return response;
071    }
072}