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