/**
   * Send INVITE message
   *
   * @param invite SIP INVITE
   * @throws SipException
   */
  @Override
  /** M: Modified to resolve the 403 error issue.@{ */
  protected void sendInvite(SipRequest invite) throws SipException {
    /** @} */
    // Send INVITE request
    SipTransactionContext ctx =
        getImsService().getImsModule().getSipManager().sendSipMessageAndWait(invite);

    // Wait response
    ctx.waitResponse(getResponseTimeout());

    // Analyze the received response
    if (ctx.isSipResponse()) {
      // A response has been received
      if (ctx.getStatusCode() == 200) {
        // 200 OK
        handle200OK(ctx.getSipResponse());
      } else if (ctx.getStatusCode() == 407) {
        // 407 Proxy Authentication Required
        handle407Authentication(ctx.getSipResponse());
      } else if (ctx.getStatusCode() == 422) {
        // 422 Session Interval Too Small
        handle422SessionTooSmall(ctx.getSipResponse());
      } else if (ctx.getStatusCode() == 603) {
        // 603 Invitation declined
        handleError(
            new FileSharingError(
                FileSharingError.SESSION_INITIATION_DECLINED, ctx.getReasonPhrase()));
      } else if (ctx.getStatusCode() == 487) {
        // 487 Invitation cancelled
        handleError(
            new FileSharingError(
                FileSharingError.SESSION_INITIATION_CANCELLED, ctx.getReasonPhrase()));
      }
      /** M: Modified to resolve the 403 error issue.@{ */
      else if (ctx.getStatusCode() == 403) {
        handle403Forbidden(invite);
      }
      /** @} */
      else {
        // Other error response
        handleError(
            new FileSharingError(
                FileSharingError.SESSION_INITIATION_FAILED,
                ctx.getStatusCode() + " " + ctx.getReasonPhrase()));
      }
    } else {
      if (logger.isActivated()) {
        logger.debug("No response received for INVITE");
      }
      /**
       * M:ALPS00507513. ADDED to reslove issue of wrong prompt in case of file transfer timeout@{
       */
      // No response received: timeout
      handleError(new FileSharingError(FileSharingError.SESSION_INITIATION_TIMEOUT));
      /** @}* */
    }
  }
예제 #2
0
  /**
   * Add a list of participants to the session
   *
   * @param participants List of participants
   */
  public void addParticipants(List<String> participants) {
    try {
      if (participants.size() == 1) {
        addParticipant(participants.get(0));
        return;
      }

      if (logger.isActivated()) {
        logger.debug("Add " + participants.size() + " participants to the session");
      }

      // Re-use INVITE dialog path
      SessionAuthenticationAgent authenticationAgent = getAuthenticationAgent();

      // Increment the Cseq number of the dialog path
      getDialogPath().incrementCseq();

      // Send REFER request
      if (logger.isActivated()) {
        logger.debug("Send REFER");
      }
      SipRequest refer = SipMessageFactory.createRefer(getDialogPath(), participants);
      SipTransactionContext ctx =
          getImsService().getImsModule().getSipManager().sendSipMessageAndWait(refer);

      // Wait response
      if (logger.isActivated()) {
        logger.debug("Wait response");
      }
      ctx.waitResponse(SipManager.TIMEOUT);

      // Analyze received message
      if (ctx.getStatusCode() == 407) {
        // 407 response received
        if (logger.isActivated()) {
          logger.debug("407 response received");
        }

        // Set the Proxy-Authorization header
        authenticationAgent.readProxyAuthenticateHeader(ctx.getSipResponse());

        // Increment the Cseq number of the dialog path
        getDialogPath().incrementCseq();

        // Create a second REFER request with the right token
        if (logger.isActivated()) {
          logger.info("Send second REFER");
        }
        refer = SipMessageFactory.createRefer(getDialogPath(), participants);

        // Set the Authorization header
        authenticationAgent.setProxyAuthorizationHeader(refer);

        // Send REFER request
        ctx = getImsService().getImsModule().getSipManager().sendSipMessageAndWait(refer);

        // Wait response
        if (logger.isActivated()) {
          logger.debug("Wait response");
        }
        ctx.waitResponse(SipManager.TIMEOUT);

        // Analyze received message
        if ((ctx.getStatusCode() >= 200) && (ctx.getStatusCode() < 300)) {
          // 200 OK response
          if (logger.isActivated()) {
            logger.debug("20x OK response received");
          }

          // Notify listeners
          for (int i = 0; i < getListeners().size(); i++) {
            ((ChatSessionListener) getListeners().get(i)).handleAddParticipantSuccessful();
          }
        } else {
          // Error
          if (logger.isActivated()) {
            logger.debug("REFER has failed (" + ctx.getStatusCode() + ")");
          }

          // Notify listeners
          for (int i = 0; i < getListeners().size(); i++) {
            ((ChatSessionListener) getListeners().get(i))
                .handleAddParticipantFailed(ctx.getReasonPhrase());
          }
        }
      } else if ((ctx.getStatusCode() >= 200) && (ctx.getStatusCode() < 300)) {
        // 200 OK received
        if (logger.isActivated()) {
          logger.debug("20x OK response received");
        }

        // Notify listeners
        for (int i = 0; i < getListeners().size(); i++) {
          ((ChatSessionListener) getListeners().get(i)).handleAddParticipantSuccessful();
        }
      } else {
        // Error responses
        if (logger.isActivated()) {
          logger.debug("No response received");
        }

        // Notify listeners
        for (int i = 0; i < getListeners().size(); i++) {
          ((ChatSessionListener) getListeners().get(i))
              .handleAddParticipantFailed(ctx.getReasonPhrase());
        }
      }
    } catch (Exception e) {
      if (logger.isActivated()) {
        logger.error("REFER request has failed", e);
      }

      // Notify listeners
      for (int i = 0; i < getListeners().size(); i++) {
        ((ChatSessionListener) getListeners().get(i)).handleAddParticipantFailed(e.getMessage());
      }
    }
  }