001/** 002 * 003 * Copyright 2017 Paul Schaub 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.transports.jingle_ibb; 018 019import java.util.WeakHashMap; 020 021import org.jivesoftware.smack.XMPPConnection; 022 023import org.jivesoftware.smackx.jingle.JingleSession; 024import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager; 025import org.jivesoftware.smackx.jingle.transports.JingleTransportManager; 026import org.jivesoftware.smackx.jingle.transports.JingleTransportSession; 027import org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport; 028import org.jivesoftware.smackx.jingle.transports.jingle_ibb.provider.JingleIBBTransportProvider; 029 030/** 031 * Manager for Jingle InBandBytestream transports (XEP-0261). 032 */ 033public final class JingleIBBTransportManager extends JingleTransportManager<JingleIBBTransport> { 034 035 private static final WeakHashMap<XMPPConnection, JingleIBBTransportManager> INSTANCES = new WeakHashMap<>(); 036 037 private JingleIBBTransportManager(XMPPConnection connection) { 038 super(connection); 039 JingleContentProviderManager.addJingleContentTransportProvider(getNamespace(), new JingleIBBTransportProvider()); 040 } 041 042 public static synchronized JingleIBBTransportManager getInstanceFor(XMPPConnection connection) { 043 JingleIBBTransportManager manager = INSTANCES.get(connection); 044 if (manager == null) { 045 manager = new JingleIBBTransportManager(connection); 046 INSTANCES.put(connection, manager); 047 } 048 return manager; 049 } 050 051 @Override 052 public String getNamespace() { 053 return JingleIBBTransport.NAMESPACE_V1; 054 } 055 056 @Override 057 public JingleTransportSession<JingleIBBTransport> transportSession(JingleSession jingleSession) { 058 return new JingleIBBTransportSession(jingleSession); 059 } 060 061 @Override 062 public void authenticated(XMPPConnection connection, boolean resumed) { 063 // Nothing to do. 064 } 065}