コード例 #1
0
C2DCallerDialog::C2DCallerDialog(const AmSipRequest& req,
const string& filename, const string& c_uri, UACAuthCred* credentials)
: filename(filename), callee_uri(c_uri), cred(credentials),
AmB2BCallerSession()
{
  set_sip_relay_only(false);
}
コード例 #2
0
SWPrepaidSIPDialog::SWPrepaidSIPDialog(AmDynInvoke* cc_acc, AmDynInvoke* user_timer)
: m_state(CC_Init),
m_cc_acc(cc_acc), m_user_timer(user_timer),
AmB2BCallerSession()

{
  set_sip_relay_only(false);
  memset(&m_acc_start, 0, sizeof(struct timeval));
}
コード例 #3
0
ファイル: MyCC.cpp プロジェクト: Chocolatbuddha/sems
MyCCDialog::MyCCDialog(AmDynInvoke* cc_acc)
  : playlist(this), 
    state(CC_Collecting_PIN),
    cc_acc(cc_acc),
    AmB2BCallerSession()
    
{
  set_sip_relay_only(false);
  memset(&acc_start, 0, sizeof(struct timeval));
}
コード例 #4
0
CallTimerDialog::CallTimerDialog(AmDynInvoke* user_timer,
				 unsigned int call_time)
: m_state(BB_Init),
  call_time(call_time),
  m_user_timer(user_timer),
  AmB2BCallerSession()

{
  set_sip_relay_only(false);
}
コード例 #5
0
DSMCall::DSMCall(const DSMScriptConfig& config,
		 AmPromptCollection* prompts,
		 DSMStateDiagramCollection& diags,
		 const string& startDiagName,
		 UACAuthCred* credentials)
  : 
  run_invite_event(config.RunInviteEvent),
  prompts(prompts), default_prompts(prompts), startDiagName(startDiagName), 
  playlist(this), cred(credentials), 
  rec_file(NULL),
  process_invite(true), process_sessionstart(true)
{
  diags.addToEngine(&engine);
  set_sip_relay_only(false);
}
コード例 #6
0
void CallTimerDialog::onInvite(const AmSipRequest& req)
{

  if (dlg.getStatus() == AmSipDialog::Connected) {
    DBG("not acting on re-Invite\n");
    return;
  }
    
  setReceiving(false);
  AmMediaProcessor::instance()->removeSession(this);

  m_state = BB_Dialing;

  if(dlg.reply(req, 100, "Trying") != 0) {
    throw AmSession::Exception(500,"Failed to reply 100");
  }

  invite_req = req;
  size_t pos1, pos2, hdr_start;

  // remove P-App-Name, P-App-Param header
  if (findHeader(invite_req.hdrs,PARAM_HDR, pos1, pos2, 
		 hdr_start)) {
    while (invite_req.hdrs[pos2]=='\r' ||invite_req.hdrs[pos2]=='\n') 
      pos2++;

    hdr_start -= 11; //"P-App-Param"
    invite_req.hdrs.erase(hdr_start, pos2-hdr_start);
  }

  if (findHeader(invite_req.hdrs,"P-App-Name", pos1, pos2, 
		 hdr_start)) {
    while (invite_req.hdrs[pos2]=='\r' ||invite_req.hdrs[pos2]=='\n') 
      pos2++;
    hdr_start -= 10; //"P-App-Name"
    invite_req.hdrs.erase(hdr_start, pos2-hdr_start);
  }

  dlg.updateStatus(invite_req);
  recvd_req.insert(std::make_pair(invite_req.cseq,invite_req));
  
  set_sip_relay_only(true);
  connectCallee(invite_req.to, invite_req.r_uri, true);
}
コード例 #7
0
void SWPrepaidSIPDialog::onInvite(const AmSipRequest& req)
{
  // TODO: do reinvites get here? if so, don't set a timer then

  // TODO: errors thrown as exception don't seem to trigger a reply?

  // this will prevent us from being added to media processor
  setInOut(NULL,NULL);

  m_uuid = getHeader(req.hdrs,"P-Caller-Uuid");
  if(!m_uuid.length()) {
    ERROR("Application header P-Caller-Uuid not found\n");
    throw AmSession::Exception(500, "could not get UUID parameter");
  }

  m_proxy = getHeader(req.hdrs,"P-Proxy");
  if(!m_proxy.length()) {
    ERROR("Application header P-Proxy not found\n");
    throw AmSession::Exception(500, "could not get PROXY parameter");
  }

  m_ruri = getHeader(req.hdrs,"P-R-Uri");
  if(!m_ruri.length()) {
    ERROR("Application header P-R-Uri not found\n");
    throw AmSession::Exception(500, "could not get RURI parameter");
  }

  m_dest = getHeader(req.hdrs,"P-Acc-Dest");

  if(!m_dest.length()) {
    ERROR("Application header P-Acc-Dest not found\n");
    throw AmSession::Exception(500, "could not get destination pattern parameter");
  }

  DBG("UUID '%s' and pattern '%s' prepared for prepaid processing\n", m_uuid.c_str(), m_dest.c_str());

  m_starttime = time(NULL);
  m_localreq = req;

  AmArg di_args,ret;
  di_args.push(m_uuid.c_str());
  di_args.push((int)m_starttime);
  di_args.push(m_dest.c_str());
  m_cc_acc->invoke("getCredit", di_args, ret);
  m_credit = ret.get(0).asInt();

  if(m_credit == -1) {
    ERROR("Failed to fetch credit from accounting module\n");
    if(dlg.reply(req, 500, "Failed to fetch credit") != 0) {
      throw AmSession::Exception(500,"Failed to fetch credit");
    }
    return;
  }
  else if(m_credit == 0) {
    DBG("No credit left\n");
    m_state = CC_Teardown;
    if(dlg.reply(req, 402, "Unsufficient Credit") != 0) {
      throw AmSession::Exception(500,"Failed to reply 402");
    }
    setStopped();
    //throw AmSession::Exception(402, "Unsufficient Credit");
  }
  else {
    DBG("Credit for UUID %s is %d seconds, calling %s now\n", m_uuid.c_str(), m_credit, req.r_uri.c_str());
    m_state = CC_Dialing;

    if(dlg.reply(req, 101, "Connecting") != 0) {
      throw AmSession::Exception(500,"Failed to reply 101");
    }

    invite_req = req;
    dlg.updateStatus(req);
    recvd_req.insert(std::make_pair(req.cseq,req));

    connectCallee("<" + m_ruri + ">", m_proxy + ";sw_prepaid", true);
    set_sip_relay_only(true);
  }
}
コード例 #8
0
void EarlyAnnounceDialog::process(AmEvent* event)
{

  AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event);
  if(audio_event && 
     (audio_event->event_id == AmAudioEvent::cleared)) {
      DBG("AmAudioEvent::cleared\n");

      bool continue_b2b = false;
      if (EarlyAnnounceFactory::ContinueB2B == 
	  EarlyAnnounceFactory::Always) {
	continue_b2b = true;
      } else if (EarlyAnnounceFactory::ContinueB2B == 
		 EarlyAnnounceFactory::AppParam) {
	string iptel_app_param = getHeader(invite_req.hdrs, PARAM_HDR);
	if (iptel_app_param.length()) {
	  continue_b2b = get_header_keyvalue(iptel_app_param,"B2B")=="yes";
	} else {
	  continue_b2b = getHeader(invite_req.hdrs,"P-B2B")=="yes";
	}
      }
      DBG("determined: continue_b2b = %s\n", continue_b2b?"true":"false");

      if (!continue_b2b) {
	unsigned int code_i = 404;
	string reason = "Not Found";
	
	string iptel_app_param = getHeader(invite_req.hdrs, PARAM_HDR);
	if (iptel_app_param.length()) {
	  string code = get_header_keyvalue(iptel_app_param,"Final-Reply-Code");
	  if (code.length() && str2i(code, code_i)) {
	    ERROR("while parsing Final-Reply-Code parameter\n");
	  }
	  reason = get_header_keyvalue(iptel_app_param,"Final-Reply-Reason");
	  if (!reason.length())
	    reason = "Not Found";
	} else {
	  string code = getHeader(invite_req.hdrs,"P-Final-Reply-Code");
	  if (code.length() && str2i(code, code_i)) {
	    ERROR("while parsing P-Final-Reply-Code\n");
	  }
	  string h_reason =  getHeader(invite_req.hdrs,"P-Final-Reply-Reason");
	  if (h_reason.length()) {
	    INFO("Use of P-Final-Reply-Code/P-Final-Reply-Reason is deprecated. ");
	    INFO("Use '%s: Final-Reply-Code=<code>;"
		 "Final-Reply-Reason=<rs>' instead.\n",PARAM_HDR);
	    reason = h_reason;
	  }
	}

	DBG("Replying with code %d %s\n", code_i, reason.c_str());
	dlg.reply(invite_req, code_i, reason);
	
	setStopped();
      } else {
	set_sip_relay_only(true);
	recvd_req.insert(std::make_pair(invite_req.cseq,invite_req));
	
	relayEvent(new B2BSipRequestEvent(invite_req,true));
      }
	
      return;
    }

  AmB2BCallerSession::process(event);
}
コード例 #9
0
EarlyAnnounceDialog::EarlyAnnounceDialog(const string& filename)
  : filename(filename)
{
  set_sip_relay_only(false);
}
コード例 #10
0
PySemsB2BDialog::PySemsB2BDialog(AmDynInvoke* user_timer)
    : playlist(this),
      user_timer(user_timer)
{
    set_sip_relay_only(false);
}
コード例 #11
0
PySemsB2BDialog::PySemsB2BDialog()
    : playlist(this),
      user_timer(NULL)
{
    set_sip_relay_only(false);
}