Java 类org.jivesoftware.smackx.packet.StreamInitiation 实例源码

项目:EIM    文件:StreamNegotiator.java   
/**
 * Creates the initiation acceptance packet to forward to the stream
 * initiator.
 *
 * @param streamInitiationOffer The offer from the stream initiator to connect for a stream.
 * @param namespaces            The namespace that relates to the accepted means of transfer.
 * @return The response to be forwarded to the initiator.
 */
public StreamInitiation createInitiationAccept(
        StreamInitiation streamInitiationOffer, String[] namespaces)
{
    StreamInitiation response = new StreamInitiation();
    response.setTo(streamInitiationOffer.getFrom());
    response.setFrom(streamInitiationOffer.getTo());
    response.setType(IQ.Type.RESULT);
    response.setPacketID(streamInitiationOffer.getPacketID());

    DataForm form = new DataForm(Form.TYPE_SUBMIT);
    FormField field = new FormField(
            FileTransferNegotiator.STREAM_DATA_FIELD_NAME);
    for (String namespace : namespaces) {
        field.addValue(namespace);
    }
    form.addField(field);

    response.setFeatureNegotiationForm(form);
    return response;
}
项目:EIM    文件:StreamNegotiator.java   
Packet initiateIncomingStream(Connection connection, StreamInitiation initiation) throws XMPPException {
    StreamInitiation response = createInitiationAccept(initiation,
            getNamespaces());

    // establish collector to await response
    PacketCollector collector = connection
            .createPacketCollector(getInitiationPacketFilter(initiation.getFrom(), initiation.getSessionID()));
    connection.sendPacket(response);

    Packet streamMethodInitiation = collector
            .nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();
    if (streamMethodInitiation == null) {
        throw new XMPPException("No response from file transfer initiator");
    }

    return streamMethodInitiation;
}
项目:androidPN-client.    文件:StreamNegotiator.java   
/**
 * Creates the initiation acceptance packet to forward to the stream
 * initiator.
 *
 * @param streamInitiationOffer The offer from the stream initiator to connect for a stream.
 * @param namespaces            The namespace that relates to the accepted means of transfer.
 * @return The response to be forwarded to the initiator.
 */
public StreamInitiation createInitiationAccept(
        StreamInitiation streamInitiationOffer, String[] namespaces)
{
    StreamInitiation response = new StreamInitiation();
    response.setTo(streamInitiationOffer.getFrom());
    response.setFrom(streamInitiationOffer.getTo());
    response.setType(IQ.Type.RESULT);
    response.setPacketID(streamInitiationOffer.getPacketID());

    DataForm form = new DataForm(Form.TYPE_SUBMIT);
    FormField field = new FormField(
            FileTransferNegotiator.STREAM_DATA_FIELD_NAME);
    for (String namespace : namespaces) {
        field.addValue(namespace);
    }
    form.addField(field);

    response.setFeatureNegotiationForm(form);
    return response;
}
项目:androidPN-client.    文件:StreamNegotiator.java   
Packet initiateIncomingStream(Connection connection, StreamInitiation initiation) throws XMPPException {
    StreamInitiation response = createInitiationAccept(initiation,
            getNamespaces());

    // establish collector to await response
    PacketCollector collector = connection
            .createPacketCollector(getInitiationPacketFilter(initiation.getFrom(), initiation.getSessionID()));
    connection.sendPacket(response);

    Packet streamMethodInitiation = collector
            .nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();
    if (streamMethodInitiation == null) {
        throw new XMPPException("No response from file transfer initiator");
    }

    return streamMethodInitiation;
}
项目:xmppsupport_v2    文件:StreamNegotiator.java   
/**
 * Creates the initiation acceptance packet to forward to the stream
 * initiator.
 * 
 * @param streamInitiationOffer
 *            The offer from the stream initiator to connect for a stream.
 * @param namespaces
 *            The namespace that relates to the accepted means of transfer.
 * @return The response to be forwarded to the initiator.
 */
public StreamInitiation createInitiationAccept(
        StreamInitiation streamInitiationOffer, String[] namespaces) {
    StreamInitiation response = new StreamInitiation();
    response.setTo(streamInitiationOffer.getFrom());
    response.setFrom(streamInitiationOffer.getTo());
    response.setType(IQ.Type.RESULT);
    response.setPacketID(streamInitiationOffer.getPacketID());

    DataForm form = new DataForm(Form.TYPE_SUBMIT);
    FormField field = new FormField(
            FileTransferNegotiator.STREAM_DATA_FIELD_NAME);
    for (String namespace : namespaces) {
        field.addValue(namespace);
    }
    form.addField(field);

    response.setFeatureNegotiationForm(form);
    return response;
}
项目:xmppsupport_v2    文件:StreamNegotiator.java   
Packet initiateIncomingStream(Connection connection,
        StreamInitiation initiation) throws XMPPException {
    StreamInitiation response = createInitiationAccept(initiation,
            getNamespaces());

    // establish collector to await response
    PacketCollector collector = connection
            .createPacketCollector(getInitiationPacketFilter(
                    initiation.getFrom(), initiation.getSessionID()));
    connection.sendPacket(response);

    Packet streamMethodInitiation = collector.nextResult(SmackConfiguration
            .getPacketReplyTimeout());
    collector.cancel();
    if (streamMethodInitiation == null) {
        throw new XMPPException("No response from file transfer initiator");
    }

    return streamMethodInitiation;
}
项目:java-bells    文件:StreamNegotiator.java   
/**
 * Creates the initiation acceptance packet to forward to the stream
 * initiator.
 *
 * @param streamInitiationOffer The offer from the stream initiator to connect for a stream.
 * @param namespaces            The namespace that relates to the accepted means of transfer.
 * @return The response to be forwarded to the initiator.
 */
public StreamInitiation createInitiationAccept(
        StreamInitiation streamInitiationOffer, String[] namespaces)
{
    StreamInitiation response = new StreamInitiation();
    response.setTo(streamInitiationOffer.getFrom());
    response.setFrom(streamInitiationOffer.getTo());
    response.setType(IQ.Type.RESULT);
    response.setPacketID(streamInitiationOffer.getPacketID());

    DataForm form = new DataForm(Form.TYPE_SUBMIT);
    FormField field = new FormField(
            FileTransferNegotiator.STREAM_DATA_FIELD_NAME);
    for (String namespace : namespaces) {
        field.addValue(namespace);
    }
    form.addField(field);

    response.setFeatureNegotiationForm(form);
    return response;
}
项目:java-bells    文件:StreamNegotiator.java   
Packet initiateIncomingStream(Connection connection, StreamInitiation initiation) throws XMPPException {
    StreamInitiation response = createInitiationAccept(initiation,
            getNamespaces());

    // establish collector to await response
    PacketCollector collector = connection
            .createPacketCollector(getInitiationPacketFilter(initiation.getFrom(), initiation.getSessionID()));
    connection.sendPacket(response);

    Packet streamMethodInitiation = collector
            .nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();
    if (streamMethodInitiation == null) {
        throw new XMPPException("No response from file transfer initiator");
    }

    return streamMethodInitiation;
}
项目:telegraph    文件:StreamNegotiator.java   
/**
 * Creates the initiation acceptance packet to forward to the stream
 * initiator.
 *
 * @param streamInitiationOffer The offer from the stream initiator to connect for a stream.
 * @param namespaces            The namespace that relates to the accepted means of transfer.
 * @return The response to be forwarded to the initiator.
 */
public StreamInitiation createInitiationAccept(
        StreamInitiation streamInitiationOffer, String[] namespaces)
{
    StreamInitiation response = new StreamInitiation();
    response.setTo(streamInitiationOffer.getFrom());
    response.setFrom(streamInitiationOffer.getTo());
    response.setType(IQ.Type.RESULT);
    response.setPacketID(streamInitiationOffer.getPacketID());

    DataForm form = new DataForm(Form.TYPE_SUBMIT);
    FormField field = new FormField(
            FileTransferNegotiator.STREAM_DATA_FIELD_NAME);
    for (String namespace : namespaces) {
        field.addValue(namespace);
    }
    form.addField(field);

    response.setFeatureNegotiationForm(form);
    return response;
}
项目:telegraph    文件:StreamNegotiator.java   
Packet initiateIncomingStream(Connection connection, StreamInitiation initiation) throws XMPPException {
    StreamInitiation response = createInitiationAccept(initiation,
            getNamespaces());

    // establish collector to await response
    PacketCollector collector = connection
            .createPacketCollector(getInitiationPacketFilter(initiation.getFrom(), initiation.getSessionID()));
    connection.sendPacket(response);

    Packet streamMethodInitiation = collector
            .nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();
    if (streamMethodInitiation == null) {
        throw new XMPPException("No response from file transfer initiator");
    }

    return streamMethodInitiation;
}
项目:NewCommunication-Android    文件:StreamNegotiator.java   
/**
 * Creates the initiation acceptance packet to forward to the stream
 * initiator.
 *
 * @param streamInitiationOffer The offer from the stream initatior to connect for a stream.
 * @param namespaces            The namespace that relates to the accepted means of transfer.
 * @return The response to be forwarded to the initator.
 */
public StreamInitiation createInitiationAccept(
        StreamInitiation streamInitiationOffer, String[] namespaces)
{
    StreamInitiation response = new StreamInitiation();
    response.setTo(streamInitiationOffer.getFrom());
    response.setFrom(streamInitiationOffer.getTo());
    response.setType(IQ.Type.RESULT);
    response.setPacketID(streamInitiationOffer.getPacketID());

    DataForm form = new DataForm(Form.TYPE_SUBMIT);
    FormField field = new FormField(
            FileTransferNegotiator.STREAM_DATA_FIELD_NAME);
    for (String namespace : namespaces) {
        field.addValue(namespace);
    }
    form.addField(field);

    response.setFeatureNegotiationForm(form);
    return response;
}
项目:NewCommunication-Android    文件:StreamNegotiator.java   
Packet initiateIncomingStream(Connection connection, StreamInitiation initiation) throws XMPPException {
    StreamInitiation response = createInitiationAccept(initiation,
            getNamespaces());

    // establish collector to await response
    PacketCollector collector = connection
            .createPacketCollector(getInitiationPacketFilter(initiation.getFrom(), initiation.getSessionID()));
    connection.sendPacket(response);

    Packet streamMethodInitiation = collector
            .nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();
    if (streamMethodInitiation == null) {
        throw new XMPPException("No response from file transfer initiator");
    }

    return streamMethodInitiation;
}
项目:EIM    文件:FileTransferManager.java   
private void initListeners() {
    listeners = new ArrayList<FileTransferListener>();

    connection.addPacketListener(new PacketListener() {
        public void processPacket(Packet packet) {
            fireNewRequest((StreamInitiation) packet);
        }
    }, new AndFilter(new PacketTypeFilter(StreamInitiation.class),
            new IQTypeFilter(IQ.Type.SET)));
}
项目:EIM    文件:FileTransferManager.java   
protected void fireNewRequest(StreamInitiation initiation) {
    FileTransferListener[] listeners = null;
    synchronized (this.listeners) {
        listeners = new FileTransferListener[this.listeners.size()];
        this.listeners.toArray(listeners);
    }
    FileTransferRequest request = new FileTransferRequest(this, initiation);
    for (int i = 0; i < listeners.length; i++) {
        listeners[i].fileTransferRequest(request);
    }
}
项目:EIM    文件:FileTransferManager.java   
protected void rejectIncomingFileTransfer(FileTransferRequest request) {
    StreamInitiation initiation = request.getStreamInitiation();

    IQ rejection = FileTransferNegotiator.createIQ(
            initiation.getPacketID(), initiation.getFrom(), initiation
                    .getTo(), IQ.Type.ERROR);
    rejection.setError(new XMPPError(XMPPError.Condition.forbidden));
    connection.sendPacket(rejection);
}
项目:EIM    文件:Socks5TransferNegotiator.java   
@Override
public InputStream createIncomingStream(StreamInitiation initiation) throws XMPPException,
                InterruptedException {
    /*
     * SOCKS5 initiation listener must ignore next SOCKS5 Bytestream request with given session
     * ID
     */
    this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID());

    Packet streamInitiation = initiateIncomingStream(this.connection, initiation);
    return negotiateIncomingStream(streamInitiation);
}
项目:EIM    文件:FileTransferNegotiator.java   
/**
 * Reject a stream initiation request from a remote user.
 *
 * @param si The Stream Initiation request to reject.
 */
public void rejectStream(final StreamInitiation si) {
    XMPPError error = new XMPPError(XMPPError.Condition.forbidden, "Offer Declined");
    IQ iqPacket = createIQ(si.getPacketID(), si.getFrom(), si.getTo(),
            IQ.Type.ERROR);
    iqPacket.setError(error);
    connection.sendPacket(iqPacket);
}
项目:EIM    文件:IBBTransferNegotiator.java   
public InputStream createIncomingStream(StreamInitiation initiation)
                throws XMPPException {
    /*
     * In-Band Bytestream initiation listener must ignore next in-band
     * bytestream request with given session ID
     */
    this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID());

    Packet streamInitiation = initiateIncomingStream(this.connection, initiation);
    return negotiateIncomingStream(streamInitiation);
}
项目:androidPN-client.    文件:FileTransferManager.java   
private void initListeners() {
    listeners = new ArrayList<FileTransferListener>();

    connection.addPacketListener(new PacketListener() {
        public void processPacket(Packet packet) {
            fireNewRequest((StreamInitiation) packet);
        }
    }, new AndFilter(new PacketTypeFilter(StreamInitiation.class),
            new IQTypeFilter(IQ.Type.SET)));
}
项目:androidPN-client.    文件:FileTransferManager.java   
protected void fireNewRequest(StreamInitiation initiation) {
    FileTransferListener[] listeners = null;
    synchronized (this.listeners) {
        listeners = new FileTransferListener[this.listeners.size()];
        this.listeners.toArray(listeners);
    }
    FileTransferRequest request = new FileTransferRequest(this, initiation);
    for (int i = 0; i < listeners.length; i++) {
        listeners[i].fileTransferRequest(request);
    }
}
项目:androidPN-client.    文件:FileTransferManager.java   
protected void rejectIncomingFileTransfer(FileTransferRequest request) {
    StreamInitiation initiation = request.getStreamInitiation();

    IQ rejection = FileTransferNegotiator.createIQ(
            initiation.getPacketID(), initiation.getFrom(), initiation
                    .getTo(), IQ.Type.ERROR);
    rejection.setError(new XMPPError(XMPPError.Condition.no_acceptable));
    connection.sendPacket(rejection);
}
项目:androidPN-client.    文件:Socks5TransferNegotiator.java   
@Override
public InputStream createIncomingStream(StreamInitiation initiation) throws XMPPException,
                InterruptedException {
    /*
     * SOCKS5 initiation listener must ignore next SOCKS5 Bytestream request with given session
     * ID
     */
    this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID());

    Packet streamInitiation = initiateIncomingStream(this.connection, initiation);
    return negotiateIncomingStream(streamInitiation);
}
项目:androidPN-client.    文件:FileTransferNegotiator.java   
/**
 * Reject a stream initiation request from a remote user.
 *
 * @param si The Stream Initiation request to reject.
 */
public void rejectStream(final StreamInitiation si) {
    XMPPError error = new XMPPError(XMPPError.Condition.forbidden, "Offer Declined");
    IQ iqPacket = createIQ(si.getPacketID(), si.getFrom(), si.getTo(),
            IQ.Type.ERROR);
    iqPacket.setError(error);
    connection.sendPacket(iqPacket);
}
项目:androidPN-client.    文件:IBBTransferNegotiator.java   
public InputStream createIncomingStream(StreamInitiation initiation)
                throws XMPPException {
    /*
     * In-Band Bytestream initiation listener must ignore next in-band
     * bytestream request with given session ID
     */
    this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID());

    Packet streamInitiation = initiateIncomingStream(this.connection, initiation);
    return negotiateIncomingStream(streamInitiation);
}
项目:xmppsupport_v2    文件:FileTransferManager.java   
private void initListeners() {
    listeners = new ArrayList<FileTransferListener>();

    connection.addPacketListener(new PacketListener() {
        public void processPacket(Packet packet) {
            fireNewRequest((StreamInitiation) packet);
        }
    }, new AndFilter(new PacketTypeFilter(StreamInitiation.class),
            new IQTypeFilter(IQ.Type.SET)));
}
项目:xmppsupport_v2    文件:FileTransferManager.java   
protected void fireNewRequest(StreamInitiation initiation) {
    FileTransferListener[] listeners = null;
    synchronized (this.listeners) {
        listeners = new FileTransferListener[this.listeners.size()];
        this.listeners.toArray(listeners);
    }
    FileTransferRequest request = new FileTransferRequest(this, initiation);
    for (int i = 0; i < listeners.length; i++) {
        listeners[i].fileTransferRequest(request);
    }
}
项目:xmppsupport_v2    文件:FileTransferManager.java   
protected void rejectIncomingFileTransfer(FileTransferRequest request) {
    StreamInitiation initiation = request.getStreamInitiation();

    IQ rejection = FileTransferNegotiator.createIQ(
            initiation.getPacketID(), initiation.getFrom(),
            initiation.getTo(), IQ.Type.ERROR);
    rejection.setError(new XMPPError(XMPPError.Condition.no_acceptable));
    connection.sendPacket(rejection);
}
项目:xmppsupport_v2    文件:Socks5TransferNegotiator.java   
@Override
public InputStream createIncomingStream(StreamInitiation initiation)
        throws XMPPException, InterruptedException {
    /*
     * SOCKS5 initiation listener must ignore next SOCKS5 Bytestream request
     * with given session ID
     */
    this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID());

    Packet streamInitiation = initiateIncomingStream(this.connection,
            initiation);
    return negotiateIncomingStream(streamInitiation);
}
项目:xmppsupport_v2    文件:FileTransferNegotiator.java   
/**
 * Reject a stream initiation request from a remote user.
 * 
 * @param si
 *            The Stream Initiation request to reject.
 */
public void rejectStream(final StreamInitiation si) {
    XMPPError error = new XMPPError(XMPPError.Condition.forbidden,
            "Offer Declined");
    IQ iqPacket = createIQ(si.getPacketID(), si.getFrom(), si.getTo(),
            IQ.Type.ERROR);
    iqPacket.setError(error);
    connection.sendPacket(iqPacket);
}
项目:xmppsupport_v2    文件:FileTransferNegotiator.java   
/**
 * Send a request to another user to send them a file. The other user has
 * the option of, accepting, rejecting, or not responding to a received file
 * transfer request.
 * <p/>
 * If they accept, the packet will contain the other user's chosen stream
 * type to send the file across. The two choices this implementation
 * provides to the other user for file transfer are <a
 * href="http://www.jabber.org/jeps/jep-0065.html">SOCKS5 Bytestreams</a>,
 * which is the preferred method of transfer, and <a
 * href="http://www.jabber.org/jeps/jep-0047.html">In-Band Bytestreams</a>,
 * which is the fallback mechanism.
 * <p/>
 * The other user may choose to decline the file request if they do not
 * desire the file, their client does not support JEP-0096, or if there are
 * no acceptable means to transfer the file.
 * <p/>
 * Finally, if the other user does not respond this method will return null
 * after the specified timeout.
 * 
 * @param userID
 *            The userID of the user to whom the file will be sent.
 * @param streamID
 *            The unique identifier for this file transfer.
 * @param fileName
 *            The name of this file. Preferably it should include an
 *            extension as it is used to determine what type of file it is.
 * @param size
 *            The size, in bytes, of the file.
 * @param desc
 *            A description of the file.
 * @param responseTimeout
 *            The amount of time, in milliseconds, to wait for the remote
 *            user to respond. If they do not respond in time, this
 * @return Returns the stream negotiator selected by the peer.
 * @throws XMPPException
 *             Thrown if there is an error negotiating the file transfer.
 */
public StreamNegotiator negotiateOutgoingTransfer(final String userID,
        final String streamID, final String fileName, final long size,
        final String desc, int responseTimeout) throws XMPPException {
    StreamInitiation si = new StreamInitiation();
    si.setSesssionID(streamID);
    si.setMimeType(URLConnection.guessContentTypeFromName(fileName));

    StreamInitiation.File siFile = new StreamInitiation.File(fileName, size);
    siFile.setDesc(desc);
    si.setFile(siFile);

    si.setFeatureNegotiationForm(createDefaultInitiationForm());

    si.setFrom(connection.getUser());
    si.setTo(userID);
    si.setType(IQ.Type.SET);

    PacketCollector collector = connection
            .createPacketCollector(new PacketIDFilter(si.getPacketID()));
    connection.sendPacket(si);
    Packet siResponse = collector.nextResult(responseTimeout);
    collector.cancel();

    if (siResponse instanceof IQ) {
        IQ iqResponse = (IQ) siResponse;
        if (iqResponse.getType().equals(IQ.Type.RESULT)) {
            StreamInitiation response = (StreamInitiation) siResponse;
            return getOutgoingNegotiator(getStreamMethodField(response
                    .getFeatureNegotiationForm()));

        } else if (iqResponse.getType().equals(IQ.Type.ERROR)) {
            throw new XMPPException(iqResponse.getError());
        } else {
            throw new XMPPException("File transfer response unreadable");
        }
    } else {
        return null;
    }
}
项目:xmppsupport_v2    文件:IBBTransferNegotiator.java   
public InputStream createIncomingStream(StreamInitiation initiation)
        throws XMPPException {
    /*
     * In-Band Bytestream initiation listener must ignore next in-band
     * bytestream request with given session ID
     */
    this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID());

    Packet streamInitiation = initiateIncomingStream(this.connection,
            initiation);
    return negotiateIncomingStream(streamInitiation);
}
项目:java-bells    文件:FileTransferManager.java   
private void initListeners() {
    listeners = new ArrayList<FileTransferListener>();

    connection.addPacketListener(new PacketListener() {
        public void processPacket(Packet packet) {
            fireNewRequest((StreamInitiation) packet);
        }
    }, new AndFilter(new PacketTypeFilter(StreamInitiation.class),
            new IQTypeFilter(IQ.Type.SET)));
}
项目:java-bells    文件:FileTransferManager.java   
protected void fireNewRequest(StreamInitiation initiation) {
    FileTransferListener[] listeners = null;
    synchronized (this.listeners) {
        listeners = new FileTransferListener[this.listeners.size()];
        this.listeners.toArray(listeners);
    }
    FileTransferRequest request = new FileTransferRequest(this, initiation);
    for (int i = 0; i < listeners.length; i++) {
        listeners[i].fileTransferRequest(request);
    }
}
项目:java-bells    文件:FileTransferManager.java   
protected void rejectIncomingFileTransfer(FileTransferRequest request) {
    StreamInitiation initiation = request.getStreamInitiation();

    IQ rejection = FileTransferNegotiator.createIQ(
            initiation.getPacketID(), initiation.getFrom(), initiation
                    .getTo(), IQ.Type.ERROR);
    rejection.setError(new XMPPError(XMPPError.Condition.no_acceptable));
    connection.sendPacket(rejection);
}
项目:java-bells    文件:Socks5TransferNegotiator.java   
@Override
public InputStream createIncomingStream(StreamInitiation initiation) throws XMPPException,
                InterruptedException {
    /*
     * SOCKS5 initiation listener must ignore next SOCKS5 Bytestream request with given session
     * ID
     */
    this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID());

    Packet streamInitiation = initiateIncomingStream(this.connection, initiation);
    return negotiateIncomingStream(streamInitiation);
}
项目:java-bells    文件:FileTransferNegotiator.java   
/**
 * Reject a stream initiation request from a remote user.
 *
 * @param si The Stream Initiation request to reject.
 */
public void rejectStream(final StreamInitiation si) {
    XMPPError error = new XMPPError(XMPPError.Condition.forbidden, "Offer Declined");
    IQ iqPacket = createIQ(si.getPacketID(), si.getFrom(), si.getTo(),
            IQ.Type.ERROR);
    iqPacket.setError(error);
    connection.sendPacket(iqPacket);
}
项目:java-bells    文件:IBBTransferNegotiator.java   
public InputStream createIncomingStream(StreamInitiation initiation)
                throws XMPPException {
    /*
     * In-Band Bytestream initiation listener must ignore next in-band
     * bytestream request with given session ID
     */
    this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID());

    Packet streamInitiation = initiateIncomingStream(this.connection, initiation);
    return negotiateIncomingStream(streamInitiation);
}
项目:telegraph    文件:FileTransferManager.java   
private void initListeners() {
    listeners = new ArrayList<FileTransferListener>();

    connection.addPacketListener(new PacketListener() {
        public void processPacket(Packet packet) {
            fireNewRequest((StreamInitiation) packet);
        }
    }, new AndFilter(new PacketTypeFilter(StreamInitiation.class),
            new IQTypeFilter(IQ.Type.SET)));
}
项目:telegraph    文件:FileTransferManager.java   
protected void fireNewRequest(StreamInitiation initiation) {
    FileTransferListener[] listeners = null;
    synchronized (this.listeners) {
        listeners = new FileTransferListener[this.listeners.size()];
        this.listeners.toArray(listeners);
    }
    FileTransferRequest request = new FileTransferRequest(this, initiation);
    for (int i = 0; i < listeners.length; i++) {
        listeners[i].fileTransferRequest(request);
    }
}
项目:telegraph    文件:FileTransferManager.java   
protected void rejectIncomingFileTransfer(FileTransferRequest request) {
    StreamInitiation initiation = request.getStreamInitiation();

    IQ rejection = FileTransferNegotiator.createIQ(
            initiation.getPacketID(), initiation.getFrom(), initiation
                    .getTo(), IQ.Type.ERROR);
    rejection.setError(new XMPPError(XMPPError.Condition.no_acceptable));
    connection.sendPacket(rejection);
}