2013-02-07 15:19:47 +01:00
|
|
|
/**
|
2014-02-19 10:38:30 +01:00
|
|
|
*
|
|
|
|
* Copyright the original author or authors
|
2013-02-07 15:19:47 +01:00
|
|
|
*
|
2014-02-17 18:57:38 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2013-02-07 15:19:47 +01:00
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2014-08-20 00:25:57 +02:00
|
|
|
package org.jivesoftware.smackx.jingleold;
|
2008-05-21 06:35:42 +02:00
|
|
|
|
2015-03-17 21:19:06 +01:00
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
2008-05-21 06:35:42 +02:00
|
|
|
import org.jivesoftware.smack.packet.IQ;
|
2017-06-14 17:12:43 +02:00
|
|
|
|
2014-08-20 00:25:57 +02:00
|
|
|
import org.jivesoftware.smackx.jingleold.packet.Jingle;
|
2008-05-21 06:35:42 +02:00
|
|
|
|
|
|
|
/**
|
2018-05-09 23:06:12 +02:00
|
|
|
* Jingle.
|
2008-05-21 06:35:42 +02:00
|
|
|
* @author Jeff Williams
|
|
|
|
* @see JingleSessionState
|
|
|
|
*/
|
2019-05-07 22:58:02 +02:00
|
|
|
@SuppressWarnings("UnusedVariable")
|
2008-05-21 06:35:42 +02:00
|
|
|
public class JingleSessionStatePending extends JingleSessionState {
|
2015-03-17 21:19:06 +01:00
|
|
|
private static final Logger LOGGER = Logger.getLogger(JingleSessionStatePending.class.getName());
|
|
|
|
|
2008-05-21 06:35:42 +02:00
|
|
|
private static JingleSessionStatePending INSTANCE = null;
|
|
|
|
|
|
|
|
protected JingleSessionStatePending() {
|
|
|
|
// Prevent instantiation of the class.
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A thread-safe means of getting the one instance of this class.
|
|
|
|
* @return The singleton instance of this class.
|
|
|
|
*/
|
2018-03-29 12:35:11 +02:00
|
|
|
public static synchronized JingleSessionState getInstance() {
|
2008-05-21 06:35:42 +02:00
|
|
|
if (INSTANCE == null) {
|
|
|
|
INSTANCE = new JingleSessionStatePending();
|
|
|
|
}
|
|
|
|
return INSTANCE;
|
|
|
|
}
|
|
|
|
|
2017-02-11 16:16:41 +01:00
|
|
|
@Override
|
2008-05-21 06:35:42 +02:00
|
|
|
public void enter() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-02-11 16:16:41 +01:00
|
|
|
@Override
|
2008-05-21 06:35:42 +02:00
|
|
|
public void exit() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-02-11 16:16:41 +01:00
|
|
|
@Override
|
2008-05-21 06:35:42 +02:00
|
|
|
public IQ processJingle(JingleSession session, Jingle jingle, JingleActionEnum action) {
|
|
|
|
IQ response = null;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
|
|
|
|
case CONTENT_ACCEPT:
|
|
|
|
response = receiveContentAcceptAction(jingle);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CONTENT_MODIFY:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CONTENT_REMOVE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SESSION_ACCEPT:
|
|
|
|
response = receiveSessionAcceptAction(session, jingle);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SESSION_INFO:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SESSION_TERMINATE:
|
|
|
|
response = receiveSessionTerminateAction(session, jingle);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TRANSPORT_INFO:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// Anything other action is an error.
|
2017-11-20 08:53:19 +01:00
|
|
|
// response = createJingleError(inJingle, JingleError.OUT_OF_ORDER);
|
2008-05-21 06:35:42 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Receive and process the <session-accept> action.
|
|
|
|
*/
|
|
|
|
private IQ receiveContentAcceptAction(Jingle inJingle) {
|
|
|
|
|
|
|
|
// According to XEP-167 the only thing we can do is ack.
|
2017-11-20 08:53:19 +01:00
|
|
|
// setSessionState(JingleSessionStateEnum.ACTIVE);
|
|
|
|
// return createAck(inJingle);
|
2008-05-21 06:35:42 +02:00
|
|
|
|
|
|
|
// This is now handled by the media negotiator for the matching <content> segment.
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Receive and process the <session-accept> action.
|
|
|
|
*/
|
|
|
|
private IQ receiveSessionAcceptAction(JingleSession session, Jingle inJingle) {
|
|
|
|
|
|
|
|
// According to XEP-166 the only thing we can do is ack.
|
|
|
|
session.setSessionState(JingleSessionStateActive.getInstance());
|
|
|
|
return session.createAck(inJingle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Receive and process the <session-terminate> action.
|
|
|
|
*/
|
|
|
|
private IQ receiveSessionTerminateAction(JingleSession session, Jingle jingle) {
|
|
|
|
|
|
|
|
// According to XEP-166 the only thing we can do is ack.
|
|
|
|
IQ response = session.createAck(jingle);
|
|
|
|
|
|
|
|
try {
|
|
|
|
session.terminate("Closed remotely");
|
2014-03-19 14:22:20 +01:00
|
|
|
} catch (Exception e) {
|
2015-03-17 21:19:06 +01:00
|
|
|
LOGGER.log(Level.WARNING, "exception", e);
|
2008-05-21 06:35:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
}
|