private OutputStream negotiateStream(String fileName, long fileSize, String description)
      throws XMPPException {
    // Negotiate the file transfer profile

    if (!updateStatus(Status.initial, Status.negotiating_transfer)) {
      throw new XMPPException("Illegal state change");
    }
    StreamNegotiator streamNegotiator =
        negotiator.negotiateOutgoingTransfer(
            getPeer(), streamID, fileName, fileSize, description, RESPONSE_TIMEOUT);

    if (streamNegotiator == null) {
      setStatus(Status.error);
      setError(Error.no_response);
      return null;
    }

    // Negotiate the stream
    if (!updateStatus(Status.negotiating_transfer, Status.negotiating_stream)) {
      throw new XMPPException("Illegal state change");
    }
    if (streamID == null) Log.e("myOutgoingFileTransfer", "null STREAMID");
    if (initiator == null) Log.e("myOutgoingFileTransfer", "null INITIATOR");
    if (getPeer() == null) Log.e("myOutgoingFileTransfer", "null GETPEER");
    outputStream = streamNegotiator.createOutgoingStream(streamID, initiator, getPeer());

    if (!updateStatus(Status.negotiating_stream, Status.negotiated)) {
      throw new XMPPException("Illegal state change");
    }
    return outputStream;
  }
Ejemplo n.º 2
0
 public PacketFilter getInitiationPacketFilter(String from, String streamID) {
   if (primaryFilter == null || secondaryFilter == null) {
     primaryFilter = primaryNegotiator.getInitiationPacketFilter(from, streamID);
     secondaryFilter = secondaryNegotiator.getInitiationPacketFilter(from, streamID);
   }
   return new OrFilter(primaryFilter, secondaryFilter);
 }
Ejemplo n.º 3
0
 public InputStream call() throws Exception {
   Packet streamInitiation =
       collector.nextResult(SmackConfiguration.getPacketReplyTimeout() * 2);
   if (streamInitiation == null) {
     throw new XMPPException("No response from remote client");
   }
   StreamNegotiator negotiator = determineNegotiator(streamInitiation);
   return negotiator.negotiateIncomingStream(streamInitiation);
 }
Ejemplo n.º 4
0
  public String[] getNamespaces() {
    String[] primary = primaryNegotiator.getNamespaces();
    String[] secondary = secondaryNegotiator.getNamespaces();

    String[] namespaces = new String[primary.length + secondary.length];
    System.arraycopy(primary, 0, namespaces, 0, primary.length);
    System.arraycopy(secondary, 0, namespaces, primary.length, secondary.length);

    return namespaces;
  }
Ejemplo n.º 5
0
  public OutputStream createOutgoingStream(String streamID, String initiator, String target)
      throws XMPPException {
    OutputStream stream;
    try {
      stream = primaryNegotiator.createOutgoingStream(streamID, initiator, target);
    } catch (XMPPException ex) {
      stream = secondaryNegotiator.createOutgoingStream(streamID, initiator, target);
    }

    return stream;
  }
 private void cleanup(final Connection connection) {
   if (transferObject.remove(connection) != null) {
     inbandTransferManager.cleanup();
   }
 }