Exemplo n.º 1
0
 /**
  * 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();
   }
 }
Exemplo n.º 2
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();
 }
Exemplo n.º 3
0
 /**
  * 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);
   }
 }
Exemplo n.º 4
0
  /** 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();
  }
Exemplo n.º 5
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());
  }