/**
  * Inherited from TransactionClientListener. When an TransactionClientListener goes into the
  * "Terminated" state, receiving a 2xx response
  *
  * <p>If called for a INVITE transaction, it updates the dialog information, moves to D_CALL
  * state, add a listener to the SipProvider, creates a new AckTransactionClient(ack,this), and
  * fires <i>onSuccessResponse(this,code,body,msg)</i>.
  *
  * <p>If called for a BYE transaction, it moves to D_CLOSE state, removes the listener from
  * SipProvider, and fires <i>onClose(this,msg)</i>.
  */
 public void onTransSuccessResponse(TransactionClient tc, Message msg) {
   printLog("inside onTransSuccessResponse(tc,msg)", LogLevel.LOW);
   if (tc.getTransactionMethod().equals(SipMethods.INVITE)) {
     if (!verifyStatus(statusIs(D_INVITING) || statusIs(D_ReINVITING))) return;
     StatusLine statusline = msg.getStatusLine();
     int code = statusline.getCode();
     if (!verifyThat(
         code >= 200 && code < 300 && msg.getTransactionMethod().equals(SipMethods.INVITE),
         "2xx for invite was expected")) return;
     boolean re_inviting = statusIs(D_ReINVITING);
     changeStatus(D_CALL);
     update(Dialog.UAC, msg);
     if (invite_offer) { // invite_req=MessageFactory.createRequest(SipMethods.ACK,dialog_state,sdp.toString());
       // ack=MessageFactory.createRequest(this,SipMethods.ACK,null);
       ack_req = MessageFactory.create2xxAckRequest(this, null);
       AckTransactionClient ack_tc = new AckTransactionClient(sip_provider, ack_req, null);
       ack_tc.request();
     }
     if (!re_inviting) {
       listener.onDlgInviteSuccessResponse(this, code, statusline.getReason(), msg.getBody(), msg);
       listener.onDlgCall(this);
     } else
       listener.onDlgReInviteSuccessResponse(
           this, code, statusline.getReason(), msg.getBody(), msg);
   } else if (tc.getTransactionMethod().equals(SipMethods.BYE)) {
     if (!verifyStatus(statusIs(D_BYEING))) return;
     StatusLine statusline = msg.getStatusLine();
     int code = statusline.getCode();
     verifyThat(code >= 200 && code < 300, "2xx for bye was expected");
     changeStatus(D_CLOSE);
     listener.onDlgByeSuccessResponse(this, code, statusline.getReason(), msg);
     listener.onDlgClose(this);
   }
 }
 /**
  * Inherited from TransactionClientListener. When the TransactionClientListener goes into the
  * "Completed" state, receiving a failure response
  *
  * <p>If called for a INVITE transaction, it moves to D_CLOSE state, removes the listener from
  * SipProvider.
  *
  * <p>If called for a BYE transaction, it moves to D_CLOSE state, removes the listener from
  * SipProvider, and fires <i>onClose(this,msg)</i>.
  */
 public void onTransFailureResponse(TransactionClient tc, Message msg) {
   printLog("inside onTransFailureResponse(" + tc.getTransactionId() + ",msg)", LogLevel.LOW);
   if (tc.getTransactionMethod().equals(SipMethods.INVITE)) {
     if (!verifyStatus(statusIs(D_INVITING) || statusIs(D_ReINVITING))) return;
     StatusLine statusline = msg.getStatusLine();
     int code = statusline.getCode();
     verifyThat(code >= 300 && code < 700, "error code was expected");
     if (statusIs(D_ReINVITING)) {
       changeStatus(D_CALL);
       listener.onDlgReInviteFailureResponse(this, code, statusline.getReason(), msg);
     } else {
       changeStatus(D_CLOSE);
       if (code >= 300 && code < 400)
         listener.onDlgInviteRedirectResponse(
             this, code, statusline.getReason(), msg.getContacts(), msg);
       else listener.onDlgInviteFailureResponse(this, code, statusline.getReason(), msg);
       listener.onDlgClose(this);
     }
   } else if (tc.getTransactionMethod().equals(SipMethods.BYE)) {
     if (!verifyStatus(statusIs(D_BYEING))) return;
     StatusLine statusline = msg.getStatusLine();
     int code = statusline.getCode();
     verifyThat(code >= 300 && code < 700, "error code was expected");
     changeStatus(InviteDialog.D_CALL);
     listener.onDlgByeFailureResponse(this, code, statusline.getReason(), msg);
   }
 }
 /**
  * Cancel the ongoing call request or a call listening. This method should be called when the
  * InviteDialog is in D_INVITING or D_ReINVITING state or in the D_WAITING state
  */
 public void cancel(Message cancel) {
   printLog("inside cancel(cancel)", LogLevel.MEDIUM);
   if (statusIs(D_INVITING) || statusIs(D_ReINVITING)) { // changeStatus(D_CANCELING);
     TransactionClient tc = new TransactionClient(sip_provider, cancel, null);
     tc.request();
   } else if (statusIs(D_WAITING) || statusIs(D_ReWAITING)) {
     invite_ts.terminate();
   }
 }
Exemple #4
0
 /** Sends a new message. */
 public void send(String recipient, String subject, String content_type, String content) {
   NameAddress to_url = new NameAddress(recipient);
   NameAddress from_url = new NameAddress(user_profile.from_url);
   MessageFactory msgf = new MessageFactory();
   Message req =
       msgf.createMessageRequest(sip_provider, to_url, from_url, subject, content_type, content);
   TransactionClient t = new TransactionClient(sip_provider, req, this);
   t.request();
 }
 /**
  * Termiante the call. This method should be called when the InviteDialog is in D_CALL state
  *
  * <p>Increments the Cseq, moves to state D_BYEING, and creates new BYE TransactionClient
  */
 public void bye(Message bye) {
   printLog("inside bye(bye)", LogLevel.MEDIUM);
   if (statusIs(D_CALL)) {
     changeStatus(D_BYEING);
     // dialog_state.incLocalCSeq(); // done by
     // MessageFactory.createRequest()
     TransactionClient tc = new TransactionClient(sip_provider, bye, this);
     tc.request();
     // listener.onDlgByeing(this);
   }
 }
  /** Sends a NOTIFY. */
  public void notify(Message req) {
    String subscription_state = req.getSubscriptionStateHeader().getState();
    if (subscription_state.equalsIgnoreCase(ACTIVE)
        && (statusIs(D_SUBSCRIBED) || statusIs(D_PENDING))) changeStatus(D_ACTIVE);
    else if (subscription_state.equalsIgnoreCase(PENDING) && statusIs(D_SUBSCRIBED))
      changeStatus(D_PENDING);
    else if (subscription_state.equalsIgnoreCase(TERMINATED) && !statusIs(D_TERMINATED))
      changeStatus(D_TERMINATED);

    TransactionClient notify_transaction = new TransactionClient(sip_provider, req, this);
    notify_transaction.request();
  }
 /**
  * Inherited from TransactionClientListener. When the TransactionClient goes into the "Terminated"
  * state, caused by transaction timeout
  */
 public void onTransTimeout(TransactionClient tc) {
   printLog("inside onTransTimeout(tc,msg)", LogLevel.LOW);
   if (tc.getTransactionMethod().equals(SipMethods.INVITE)) {
     if (!verifyStatus(statusIs(D_INVITING) || statusIs(D_ReINVITING))) return;
     cancel(); // modified
     changeStatus(D_CLOSE);
     listener.onDlgTimeout(this);
     listener.onDlgClose(this);
   } else if (tc.getTransactionMethod().equals(SipMethods.BYE)) {
     if (!verifyStatus(statusIs(D_BYEING))) return;
     changeStatus(D_CLOSE);
     listener.onDlgClose(this);
   }
 }
 /**
  * Inherited from TransactionClientListener. When the TransactionClientListener is in "Proceeding"
  * state and receives a new 1xx response
  *
  * <p>For INVITE transaction it fires <i>onFailureResponse(this,code,reason,body,msg)</i>.
  */
 public void onTransProvisionalResponse(TransactionClient tc, Message msg) {
   printLog("inside onTransProvisionalResponse(tc,mdg)", LogLevel.LOW);
   if (tc.getTransactionMethod().equals(SipMethods.INVITE)) {
     StatusLine statusline = msg.getStatusLine();
     listener.onDlgInviteProvisionalResponse(
         this, statusline.getCode(), statusline.getReason(), msg.getBody(), msg);
   }
 }
Exemple #9
0
 /** When the delivery fails. */
 private void onDeliveryFailure(TransactionClient tc, String result) {
   printLog("Message delivery failed (" + result + ").");
   Message req = tc.getRequestMessage();
   NameAddress recipient = req.getToHeader().getNameAddress();
   String subject = null;
   if (req.hasSubjectHeader()) subject = req.getSubjectHeader().getSubject();
   if (listener != null) listener.onMaDeliveryFailure(this, recipient, subject, result);
 }
Exemple #10
0
  /** When the TransactionClient goes into the "Completed" state receiving a 300-699 response */
  public void onTransFailureResponse(TransactionClient tc, Message msg) {
    // SESCA
    // Autentikointi
    String method = tc.getTransactionMethod();
    StatusLine status_line = msg.getStatusLine();
    int code = status_line.getCode();
    // AUTHENTICATION-BEGIN
    if ((code == 401
            && msg.hasWwwAuthenticateHeader()
            && msg.getWwwAuthenticateHeader().getRealmParam().equalsIgnoreCase(user_profile.realm))
        || (code == 407
            && msg.hasProxyAuthenticateHeader()
            && msg.getProxyAuthenticateHeader()
                .getRealmParam()
                .equalsIgnoreCase(user_profile.realm))) {
      // req:ssa on cseq:ua kasvatettu
      Message req = tc.getRequestMessage();
      req.setCSeqHeader(req.getCSeqHeader().incSequenceNumber());
      WwwAuthenticateHeader wah;
      if (code == 401) wah = msg.getWwwAuthenticateHeader();
      else wah = msg.getProxyAuthenticateHeader();
      String qop_options = wah.getQopOptionsParam();
      qop = (qop_options != null) ? "auth" : null;
      RequestLine rl = req.getRequestLine();
      // SESCA
      // BUGI client ei saa lähettää qop:ia
      // DigestAuthentication digest=new
      // DigestAuthentication(rl.getMethod(),rl.getAddress().toString(),wah,qop,null,username,passwd);
      DigestAuthentication digest =
          new DigestAuthentication(
              rl.getMethod(),
              rl.getAddress().toString(),
              wah,
              null,
              null,
              user_profile.authID,
              user_profile.passwd);
      AuthorizationHeader ah;
      if (code == 401) ah = digest.getAuthorizationHeader();
      else ah = digest.getProxyAuthorizationHeader();
      req.setAuthorizationHeader(ah);
      //	         transactions.remove(tc.getTransactionId());
      // SESCA
      // BUGI
      // Päivitetään invite_req:uun uusin invite-viesti.
      // Lähetämme uuden inviten, joten teemme uuden invitetransactionclientin, eikä transaction
      // clientia
      //	         if (method.equals(SipMethods.INVITE)) {
      //	        	 invite_req = req;
      //	        	 tc=new InviteTransactionClient(sip_provider,req,this);
      tc = new TransactionClient(sip_provider, req, this);
      //	        	 tc=new TransactionClient(sip_provider,req,this);
      //	         }
      //	         else {
      //	        	 tc=new TransactionClient(sip_provider,req,this);
      //	        	 }
      //	         transactions.put(tc.getTransactionId(),tc);
      tc.request();

    }
    // AUTHENTICATION-END
    else onDeliveryFailure(tc, msg.getStatusLine().getReason());
  }