int AnnouncementFactory::onLoad()
{
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
    return -1;

  // get application specific global parameters
  configureModule(cfg);

  AnnouncePath = cfg.getParameter("announce_path",ANNOUNCE_PATH);
  if( !AnnouncePath.empty() 
      && AnnouncePath[AnnouncePath.length()-1] != '/' )
    AnnouncePath += "/";

  AnnounceFile = cfg.getParameter("default_announce",ANNOUNCE_FILE);

  string announce_file = AnnouncePath + AnnounceFile;
  if(!file_exists(announce_file)){
    ERROR("default file for announcement module does not exist ('%s').\n",
	  announce_file.c_str());
    return -1;
  }

  return 0;
}
Beispiel #2
0
int AnnRecorderFactory::onLoad()
{
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
    return -1;

  // get application specific global parameters
  configureModule(cfg);

  AnnouncePath = cfg.getParameter("announce_path",ANNOUNCE_PATH);
  if( !AnnouncePath.empty() 
      && AnnouncePath[AnnouncePath.length()-1] != '/' )
    AnnouncePath += "/";
  DefaultAnnounce = cfg.getParameter("default_announce");

  SimpleMode = (cfg.getParameter("simple_mode") == "yes");

  AM_PROMPT_START;
  AM_PROMPT_ADD(WELCOME, ANNREC_ANNOUNCE_PATH WELCOME".wav");
  AM_PROMPT_ADD(YOUR_PROMPT, ANNREC_ANNOUNCE_PATH YOUR_PROMPT".wav");
  AM_PROMPT_ADD(TO_RECORD, ANNREC_ANNOUNCE_PATH TO_RECORD".wav");
  AM_PROMPT_ADD(CONFIRM, ANNREC_ANNOUNCE_PATH CONFIRM".wav");
  AM_PROMPT_ADD(GREETING_SET, ANNREC_ANNOUNCE_PATH GREETING_SET".wav");
  AM_PROMPT_ADD(BYE, ANNREC_ANNOUNCE_PATH BYE".wav");
  AM_PROMPT_ADD(BEEP, ANNREC_ANNOUNCE_PATH BEEP".wav");
  AM_PROMPT_END(prompts, cfg, MOD_NAME);

  message_storage_fact = AmPlugIn::instance()->getFactory4Di("msg_storage");
  if(!message_storage_fact) {
    ERROR("sorry, could not get msg_storage, please load a suitable plug-in\n");
    return -1;
  }

  return 0;
}
Beispiel #3
0
bool DSMFactory::loadPromptSets(AmConfigReader& cfg) {
  string prompt_sets_path = cfg.getParameter("prompts_sets_path");

  vector<string> prompt_sets_names = 
    explode(cfg.getParameter("load_prompts_sets"), ",");
  for (vector<string>::iterator it=
	 prompt_sets_names.begin(); it != prompt_sets_names.end(); it++) {
    string fname = prompt_sets_path.empty() ? "": prompt_sets_path + "/";
    fname += *it;
    DBG("loading prompts for '%s' (file '%s')\n", it->c_str(), fname.c_str());
    std::ifstream ifs(fname.c_str());
    string s;
    if (!ifs.good()) {
      WARN("prompts set file '%s' could not be read\n", fname.c_str());
    }
    AmPromptCollection* pc = new AmPromptCollection();
    while (ifs.good() && !ifs.eof()) {
      getline(ifs, s);
      if (s.length() && s.find_first_not_of(" \t")!= string::npos &&
	  s[s.find_first_not_of(" \t")] != '#') {
        vector<string> p=explode(s, "=");
	if (p.size()==2) {
	  pc->setPrompt(p[0], p[1], MOD_NAME);
	  DBG("set '%s' added prompt '%s' as '%s'\n", 
	      it->c_str(), p[0].c_str(), p[1].c_str());
	}
      }
    }
    prompt_sets[*it] = pc;
  }
  return true;
}
Beispiel #4
0
int MWI::onLoad()
{
  AmDynInvokeFactory* ms_fact = 
    AmPlugIn::instance()->getFactory4Di("msg_storage");

  if(!ms_fact || !(MessageStorage = ms_fact->getInstance())) {
    ERROR("could not load msg_storage. Load a msg_storage implementation module.\n");
    return -1;
  };

  // register the publish method as event sink for msg_storage events
  AmArg es_args,ret;
  es_args.push(this);
  es_args.push("publish");
  MessageStorage->invoke("events_subscribe",es_args,ret);
  
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + "mwi.conf")) {
    ERROR("can not load configuration file\n");
    return -1;
  };
  
  presence_server = cfg.getParameter("presence_server");
  if (presence_server.length())
    DBG("set presence server '%s'\n", presence_server.c_str());
  else {
    ERROR("parameter 'presence_server' did not found in the configuration file\n");
    return -1;
  }                
  
  DBG("MWI module loaded.\n");
  return 0;
};
Beispiel #5
0
int AmZRTP::init() {
  AmConfigReader cfg;
  string cfgname=add2path(AmConfig::ModConfigPath, 1,  "zrtp.conf");
  if(cfg.loadFile(cfgname)) {
    ERROR("No %s config file present.\n", 
	  cfgname.c_str());
    return -1;
  }
  cache_path = cfg.getParameter("cache_path");
  string zid = cfg.getParameter("zid");
  if (zid.length() != sizeof(zrtp_zid_t)) {
    ERROR("ZID of this instance MUST be set for ZRTP.\n");
    ERROR("ZID needs to be %u characters long.\n", 
	  sizeof(zrtp_zid_t));
    return -1;
  }
  for (int i=0;i<12;i++)
    zrtp_instance_zid[i]=zid[i];

  DBG("initializing ZRTP library with ZID '%s', cache path '%s'.\n",
      zid.c_str(), cache_path.c_str());
  if ( zrtp_status_ok != zrtp_init(&zrtp_global, "zrtp_sems") ) {
    ERROR("Some error during zrtp initialization\n");
    return -1;
  }
  zrtp_add_entropy(&zrtp_global, NULL, 0);
  DBG("ZRTP initialized ok.\n");

  return 0;
}
Beispiel #6
0
int MsgStorage::onLoad() {

  msg_dir = MSG_DIR;
  
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) {
    DBG("no configuration could be loaded, assuming defaults.\n");
  } else {
      msg_dir = cfg.getParameter("storage_dir",MSG_DIR);
      DBG("storage_dir set to '%s'.\n", msg_dir.c_str());
  }

  string path = msg_dir;
  int status = mkdir(path.c_str(), 
		     S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
  if (status && (errno != EEXIST)) {
    ERROR("creating storage path '%s': %s\n", 
	  path.c_str(),strerror(errno));
    return -1;
  }

  path = msg_dir + "/_test_dir_";
  status = mkdir(path.c_str(), 
		     S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
  if (status && (errno != EEXIST)) {
    ERROR("Write permission check failed. Could not create '%s': %s\n", 
	  path.c_str(),strerror(errno));
    return -1;
  }
  rmdir(path.c_str());

  DBG("MsgStorage loaded.\n");
  return 0;
}
Beispiel #7
0
bool DSMFactory::loadDiags(AmConfigReader& cfg, DSMStateDiagramCollection* m_diags) {
  string DiagPath = cfg.getParameter("diag_path");
  if (DiagPath.length() && DiagPath[DiagPath.length()-1] != '/')
    DiagPath += '/';

  string ModPath = cfg.getParameter("mod_path");

  string err;
  int res = preloadModules(cfg, err, ModPath);
  if (res<0) {
    ERROR("%s\n", err.c_str());
    return false;
  }

  // todo: pass preloaded mods to chart reader

  string LoadDiags = cfg.getParameter("load_diags");
  vector<string> diags_names = explode(LoadDiags, ",");
  for (vector<string>::iterator it=
	 diags_names.begin(); it != diags_names.end(); it++) {
    if (!m_diags->loadFile(DiagPath+*it+".dsm", *it, ModPath, DebugDSM)) {
      ERROR("loading %s from %s\n", 
	    it->c_str(), (DiagPath+*it+".dsm").c_str());
      return false;
    }
  }

  return true;
}
Beispiel #8
0
/** @return whether successful */
bool readFilter(AmConfigReader& cfg, const char* cfg_key_filter, const char* cfg_key_list,
		vector<FilterEntry>& filter_list, bool keep_transparent_entry) {
    string filter = cfg.getParameter(cfg_key_filter);
    if (filter.empty())
	return true;

    FilterEntry hf;
    hf.filter_type = String2FilterType(filter.c_str());
    if (Undefined == hf.filter_type) {
	ERROR("invalid %s mode '%s'\n", cfg_key_filter, filter.c_str());
	return false;
    }

    // no transparent filter
    if (!keep_transparent_entry && hf.filter_type==Transparent)
	return true;

    vector<string> elems = explode(cfg.getParameter(cfg_key_list), ",");
    for (vector<string>::iterator it=elems.begin(); it != elems.end(); it++) {
	string c = *it;
	std::transform(c.begin(), c.end(), c.begin(), ::tolower);
	hf.filter_list.insert(c);
    }

    filter_list.push_back(hf);
    return true;
}
int BrpcCtrlInterfaceFactory::onLoad()
{
  AmConfigReader cfg;
  unsigned int ct_to, rx_to, tx_to;

  if (cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) {
    WARN("failed to read/parse config file `%s' - assuming defaults\n",
      (AmConfig::ModConfigPath + string(MOD_NAME ".conf")).c_str());
    semsUri = string(LISTEN_ADDR_DEFAULT);
    serUri = string(SER_ADDR_DEFAULT);
  } else {
    semsUri = cfg.getParameter(LISTEN_ADDR_PARAM, LISTEN_ADDR_DEFAULT);
    serUri = cfg.getParameter(SER_ADDR_PARAM, SER_ADDR_DEFAULT);

    if (str2i(cfg.getParameter(CT_TIMEOUT_PARAM, int2str(CT_TIMEOUT)), 
        ct_to)) {
      ERROR("failed to read `%s' param from config file.\n", CT_TIMEOUT_PARAM);
      return -1;
    } else {
      ct_timeout = ct_to * 1000;
    }
    if (str2i(cfg.getParameter(RX_TIMEOUT_PARAM, int2str(RX_TIMEOUT)), 
        rx_to)) {
      ERROR("failed to read `%s' param from config file.\n", RX_TIMEOUT_PARAM);
      return -1;
    } else {
      rx_timeout = rx_to * 1000;
    }
    if (str2i(cfg.getParameter(TX_TIMEOUT_PARAM, int2str(TX_TIMEOUT)), 
        tx_to)) {
      ERROR("failed to read `%s' param from config file.\n", TX_TIMEOUT_PARAM);
      return -1;
    } else {
      tx_timeout = tx_to * 1000;
    }


    if (str2i(cfg.getParameter(RX_WORKERS_PARAM, int2str(RX_WORKERS)), 
        rx_workers)) {
      ERROR("failed to read `%s' param from config file.\n", RX_WORKERS_PARAM);
      return -1;
    }
    if (str2i(cfg.getParameter(TX_WORKERS_PARAM, int2str(TX_WORKERS)), 
        tx_workers)) {
      ERROR("failed to read `%s' param from config file.\n", TX_WORKERS_PARAM);
      return -1;
    }
  }
  INFO(LISTEN_ADDR_PARAM ": %s.\n", semsUri.c_str());
  INFO(SER_ADDR_PARAM ": %s.\n", serUri.c_str());
  INFO(CT_TIMEOUT_PARAM ": %uus.\n", (unsigned)ct_timeout);
  INFO(RX_TIMEOUT_PARAM ": %uus.\n", (unsigned)rx_timeout);
  INFO(TX_TIMEOUT_PARAM ": %uus.\n", (unsigned)tx_timeout);
  INFO(RX_WORKERS_PARAM ": %u.\n", rx_workers);
  INFO(TX_WORKERS_PARAM ": %u.\n", tx_workers);

  return 0;
}
Beispiel #10
0
int DIDialFactory::onLoad(){
  
  AmConfigReader cfg;
  if(!cfg.loadFile(AmConfig::ModConfigPath + string(APP_NAME)+ ".conf")) {

    unsigned int i_pin = 0;
    while (i_pin<100) { // only for safety..
      string dialout_pin = cfg.getParameter("dialout_pin"+int2str(i_pin));
      if (!dialout_pin.length()) 
	break;
      size_t pos = dialout_pin.find_first_of(';');
      if (pos == string::npos)
	break;
      string pin = dialout_pin.substr(0, pos);
      
      size_t pos2 = dialout_pin.find_first_of(';', pos+1);
      if ((pos == string::npos)||(pos2 == string::npos))
	break;
      string userpart = dialout_pin.substr(pos+1, pos2-pos-1);
      pos = pos2;

      pos2 = dialout_pin.find_first_of(';', pos+1);
      if ((pos == string::npos)||(pos2 == string::npos))
	break;
      string user = dialout_pin.substr(pos+1, pos2-pos-1);
      pos = pos2;

      pos2 = dialout_pin.find_first_of(';', pos+1);
      if ((pos == string::npos)||(pos2 == string::npos))
	break;
      string domain = dialout_pin.substr(pos+1, pos2-pos-1);
      pos = pos2;

      pos2 = dialout_pin.find_first_of(';', pos+1);
      if ((pos == string::npos)||(pos2 == string::npos))
	break;
      string pwd = dialout_pin.substr(pos+1, pos2-pos-1);
      pos = pos2;

      dialout_pins[pin] = DIDialoutInfo(userpart, domain, user, pwd);
      DBG("DIDial: added PIN '%s' userpart '%s' domain '%s' user '%s' pwd '<not shown>'\n", 
	  pin.c_str(), userpart.c_str(), domain.c_str(), user.c_str());
      i_pin++;		
    } 
  } else {
    DBG("no configuration for di_dial found. No dialout pins will be set.\n");
  }
  
  DBG("DIDial loaded.\n");
  return 0;
}
Beispiel #11
0
int MyCCFactory::onLoad()
{
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
    return -1;
  
  InitialAnnouncement = cfg.getParameter("initial_announcement", "/tmp/hello.wav");
  IncorrectPIN        = cfg.getParameter("incorrect_pin", "/tmp/incorrect_pin.wav");
  OutOfCredit         = cfg.getParameter("out_of_credit", "/tmp/out_of_credit.wav");
  Dialing             = cfg.getParameter("dialing", "/tmp/dialing.wav");
  DialFailed          = cfg.getParameter("dial_failed", "/tmp/dial_failed.wav");
  EnterNumber         = cfg.getParameter("enter_number", "/tmp/enter_number.wav"); 
  ConnectSuffix       = cfg.getParameter("connect_suffix", "@127.0.0.1"); 

  user_timer_fact = AmPlugIn::instance()->getFactory4Di("user_timer");
  if(!user_timer_fact){
    ERROR("could not load user_timer from session_timer plug-in\n");
    return -1;
  }
  cc_acc_fact = AmPlugIn::instance()->getFactory4Di("cc_acc");
  if(!cc_acc_fact){
    ERROR("could not load cc_acc accounting, please provide a module\n");
    return -1;
  }

  return 0;
}
int MyConfigurableAppFactory::onLoad()
{
    AmConfigReader cfg;
    if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
	return -1;

    AnnouncementFile = cfg.getParameter("announcement_file","/tmp/default.wav");

    if(!file_exists(AnnouncementFile)){
	ERROR("announcement file for configurableApp module does not exist ('%s').\n",
	      AnnouncementFile.c_str());
	return -1;
    }

    return 0;
}
int SipCtrlInterfaceFactory::onLoad()
{
    
    bind_addr = AmConfig::LocalSIPIP;
    bind_port = AmConfig::LocalSIPPort;
  
    INFO("SIP bind_addr: `%s'.\n", bind_addr.c_str());
    INFO("SIP bind_port: `%i'.\n", bind_port);

    if (!AmConfig::OutboundProxy.empty()) {
	sip_uri parsed_uri;
	if (parse_uri(&parsed_uri, (char *)AmConfig::OutboundProxy.c_str(),
		      AmConfig::OutboundProxy.length()) < 0) {
	    ERROR("invalid outbound_proxy specified\n");
	    return -1;
	}
	SipCtrlInterfaceFactory::outbound_host = c2stlstr(parsed_uri.host);
	if (parsed_uri.port) {
	    SipCtrlInterfaceFactory::outbound_port = parsed_uri.port;
	}
    }

    AmConfigReader cfg;
    string cfgfile = AmConfig::ModConfigPath + string(MOD_NAME ".conf");
    if (file_exists(cfgfile) && !cfg.loadFile(cfgfile)) {
	if (cfg.hasParameter("accept_fr_without_totag")) {
	    accept_fr_without_totag = 
		cfg.getParameter("accept_fr_without_totag") == "yes";
	}
	DBG("sipctrl: accept_fr_without_totag = %s\n", 
	    accept_fr_without_totag?"yes":"no");

	if (cfg.hasParameter("log_raw_messages")) {
	    string msglog = cfg.getParameter("log_raw_messages");
	    if (msglog == "no") log_raw_messages = -1;
	    else if (msglog == "error") log_raw_messages = 0;
	    else if (msglog == "warn")  log_raw_messages = 1;
	    else if (msglog == "info")  log_raw_messages = 2;
	    else if (msglog == "debug") log_raw_messages = 3;
	}
	DBG("sipctrl: log_raw_messages level = %d\n", 
	    log_raw_messages);

	if (cfg.hasParameter("log_parsed_messages")) {
	    log_parsed_messages = cfg.getParameter("log_parsed_messages")=="yes";
	}
	DBG("sipctrl: log_parsed_messages = %s\n", 
	    log_parsed_messages?"yes":"no");

    } else {
	DBG("assuming SIP default settings.\n");
    }

    return 0;
    
}
int AnswerMachineFactory::onLoad()
{
    AmConfigReader cfg;
    if(cfg.loadFile(add2path(AmConfig::ModConfigPath,1, MOD_NAME ".conf")))
	return -1;

    // get application specific global parameters
    configureModule(cfg);

    AnnouncePath    = cfg.getParameter("announce_path",ANNOUNCE_PATH);
    DefaultAnnounce = cfg.getParameter("default_announce",DEFAULT_ANNOUNCE);
    MaxRecordTime   = cfg.getParameterInt("max_record_time",DEFAULT_RECORD_TIME);
    RecFileExt      = cfg.getParameter("rec_file_ext",DEFAULT_AUDIO_EXT);

    if(loadEmailTemplates(cfg.getParameter("email_template_path",DEFAULT_MAIL_TMPL_PATH))){
	ERROR("while loading email templates\n");
	return -1;
    }

    AcceptDelay = DEFAULT_ACCEPT_DELAY;

    UserTimer = AmPlugIn::instance()->getFactory4Di("user_timer");
    if(!UserTimer){
	
	ERROR("could not load user_timer from session_timer plug-in\n");
	return -1;
    }

    return 0;
}
int BrpcCtrlInterfaceFactory::onLoad()
{
    AmConfigReader cfg;

    if (cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) {
        WARN("failed to read/parse config file `%s' - assuming defaults\n",
             (AmConfig::ModConfigPath + string(MOD_NAME ".conf")).c_str());
        semsUri = string(LISTEN_ADDR_DEFAULT);
        serUri = string(SER_ADDR_DEFAULT);
    } else {
        semsUri = cfg.getParameter(LISTEN_ADDR_PARAM, LISTEN_ADDR_DEFAULT);
        serUri = cfg.getParameter(SER_ADDR_PARAM, SER_ADDR_DEFAULT);
    }
    INFO(LISTEN_ADDR_PARAM ": %s.\n", semsUri.c_str());
    INFO(SER_ADDR_PARAM ": %s.\n", serUri.c_str());

    return 0;
}
Beispiel #16
0
int CallTimerFactory::onLoad()
{
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) {
    DBG("using default timer of %d seconds\n", DEFAULT_CALL_TIMER);
    DefaultCallTimer = DEFAULT_CALL_TIMER;
  } else {
    DefaultCallTimer  = cfg.getParameterInt("default_call_time", DEFAULT_CALL_TIMER);
    UseAppParam = (cfg.getParameter("use_app_param") == "yes");
  }

  user_timer_fact = AmPlugIn::instance()->getFactory4Di("user_timer");
  if(!user_timer_fact) {
    ERROR("could not load user_timer from session_timer plug-in\n");
    return -1;
  }

  return 0;
}
Beispiel #17
0
static int readRTPInterface(AmConfigReader& cfg, const string& i_name)
{
  int ret=0;
  AmConfig::RTP_interface intf;

  string suffix;
  if(!i_name.empty())
    suffix = "_" + i_name;

  // media_ip
  if(cfg.hasParameter("media_ip" + suffix)) {
    intf.LocalIP = cfg.getParameter("media_ip" + suffix);
  }
  else {
    // no media definition for this interface name
    return 0;
  }

  // public_ip
  if(cfg.hasParameter("public_ip" + suffix)){
    intf.PublicIP = cfg.getParameter("public_ip" + suffix);
  }

  // rtp_low_port
  if(cfg.hasParameter("rtp_low_port" + suffix)){
    string rtp_low_port_str = cfg.getParameter("rtp_low_port" + suffix);
    if(sscanf(rtp_low_port_str.c_str(),"%u",
	      &(intf.RtpLowPort)) != 1){
      ERROR("rtp_low_port%s: invalid port number (%s)\n",
	    suffix.c_str(),rtp_low_port_str.c_str());
      ret = -1;
    }
  }

  // rtp_high_port
  if(cfg.hasParameter("rtp_high_port" + suffix)){
    string rtp_high_port_str = cfg.getParameter("rtp_high_port" + suffix);
    if(sscanf(rtp_high_port_str.c_str(),"%u",
	      &(intf.RtpHighPort)) != 1){
      ERROR("rtp_high_port%s: invalid port number (%s)\n",
	    suffix.c_str(),rtp_high_port_str.c_str());
      ret = -1;
    }
  }

  if(!i_name.empty())
    intf.name = i_name;
  else
    intf.name = "default";

  return AmConfig::insert_RTP_interface(intf);
}
int PinAuthConferenceFactory::onLoad()
{
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + string(APP_NAME)+ ".conf"))
    return -1;

  // get application specific global parameters
  configureModule(cfg);

  // get prompts
  AM_PROMPT_START;
  AM_PROMPT_ADD(FIRST_PARTICIPANT, ANNOUNCE_PATH "first_paricipant.wav");
  AM_PROMPT_ADD(JOIN_SOUND,        ANNOUNCE_PATH "beep.wav");
  AM_PROMPT_ADD(DROP_SOUND,        ANNOUNCE_PATH "beep.wav");
  AM_PROMPT_ADD(ENTER_PIN,         ANNOUNCE_PATH "enter_pin.wav");
  AM_PROMPT_ADD(WRONG_PIN,         ANNOUNCE_PATH "wrong_pin.wav");
  AM_PROMPT_ADD(ENTERING_CONFERENCE, ANNOUNCE_PATH "entering_conference.wav");
  AM_PROMPT_END(prompts, cfg, APP_NAME);

  DigitsDir = cfg.getParameter("digits_dir");
  if (DigitsDir.length() && DigitsDir[DigitsDir.length()-1]!='/')
    DigitsDir+='/';

  if (!DigitsDir.length()) {
    WARN("No digits_dir specified in configuration.\n");
  }
  for (int i=0;i<10;i++) 
    prompts.setPrompt(int2str(i), DigitsDir+int2str(i)+".wav", APP_NAME);

  string playout_type = cfg.getParameter("playout_type");
  if (playout_type == "simple") {
    m_PlayoutType = SIMPLE_PLAYOUT;
    DBG("Using simple (fifo) buffer as playout technique.\n");
  } else 	if (playout_type == "adaptive_jb") {
    m_PlayoutType = JB_PLAYOUT;
    DBG("Using adaptive jitter buffer as playout technique.\n");
  } else {
    DBG("Using adaptive playout buffer as playout technique.\n");
  }

  return 0;
}
Beispiel #19
0
void DSMFactory::preloadModules(const AmArg& args, AmArg& ret) {
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) {
      ret.push(500);
      ret.push("loading config file " +AmConfig::ModConfigPath + string(MOD_NAME ".conf"));
      return ;
  }
  string err;

  string ModPath = cfg.getParameter("mod_path");

  int res = preloadModules(cfg, err, ModPath);
  if (res<0) {
    ret.push(500);
    ret.push(err);
  } else {
    ret.push(200);
    ret.push("modules preloaded");
  }
}
Beispiel #20
0
int UACAuthFactory::onLoad()
{
  string secret;
  AmConfigReader conf;
  string cfg_file_path = AmConfig::ModConfigPath + "uac_auth.conf";
  if(conf.loadFile(cfg_file_path)){
    WARN("Could not open '%s', assuming that default values are fine\n",
	 cfg_file_path.c_str());
    secret = AmSession::getNewId(); // ?? TODO: is this cryptoproof?
  } else {
    secret = conf.getParameter("server_secret");
    if (secret.size()<5) {
      ERROR("server_secret in '%s' too short!\n", cfg_file_path.c_str());
      return -1;
    }
  }

  UACAuth::setServerSecret(secret);
  return 0;
}
Beispiel #21
0
int JsonRPCServerModule::load() {
  
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + 
		  string(MOD_NAME ".conf"))) {
    INFO("no '%s' configuration file present. using default values\n",
	 (AmConfig::ModConfigPath + string(MOD_NAME ".conf")).c_str());
  } else {
    port = cfg.getParameterInt("jsonrpc_port", DEFAULT_JSONRPC_SERVER_PORT);
    threads = cfg.getParameterInt("server_threads", DEFAULT_JSONRPC_SERVER_THREADS);
  }

  DBG("using server port %d\n", port);
  DBG("using %d server threads\n", threads);

  DBG("starting server loop thread\n");
  server_loop = new JsonRPCServerLoop();
  server_loop->start();
  
  return 0;
}
Beispiel #22
0
int AmSessionTimerConfig::readFromConfig(AmConfigReader& cfg)
{
  // enable_session_timer
  if(cfg.hasParameter("enable_session_timer")){
    if(!setEnableSessionTimer(cfg.getParameter("enable_session_timer"))){
      ERROR("invalid enable_session_timer specified\n");
      return -1;
    }
  }

  // session_expires
  if(cfg.hasParameter("session_expires")){
    if(!setSessionExpires(cfg.getParameter("session_expires"))){
      ERROR("invalid session_expires specified\n");
      return -1;
    }
  }

  // minimum_timer
  if(cfg.hasParameter("minimum_timer")){
    if(!setMinimumTimer(cfg.getParameter("minimum_timer"))){
      ERROR("invalid minimum_timer specified\n");
      return -1;
    }
  }
  return 0;
}
Beispiel #23
0
bool DSMFactory::loadPrompts(AmConfigReader& cfg) {

  vector<string> prompts_files = 
    explode(cfg.getParameter("load_prompts"), ",");
  for (vector<string>::iterator it=
	 prompts_files.begin(); it != prompts_files.end(); it++) {
    DBG("loading prompts from '%s'\n", it->c_str());
    std::ifstream ifs(it->c_str());
    string s;
    while (ifs.good() && !ifs.eof()) {
      getline(ifs, s);
      if (s.length() && s.find_first_not_of(" \t")!= string::npos &&
	  s[s.find_first_not_of(" \t")] != '#') {
        vector<string> p=explode(s, "=");
	if (p.size()==2) {
	  prompts.setPrompt(p[0], p[1], MOD_NAME);
	  DBG("added prompt '%s' as '%s'\n", 
	      p[0].c_str(), p[1].c_str());
	}
      }
    }
  }

  bool has_all_prompts = true;
  vector<string> required_prompts = 
    explode(cfg.getParameter("required_prompts"), ",");
  
  for (vector<string>::iterator it=required_prompts.begin(); 
       it != required_prompts.end(); it++) {
    if (!prompts.hasPrompt(*it)) {
      ERROR("required prompt '%s' not loaded.\n",
	    it->c_str());
      has_all_prompts = false;
    }
  }
  if (!has_all_prompts)
    return false;

  return true;
}
int AnnounceAuthFactory::onLoad()
{
    AmConfigReader cfg;
    if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
	return -1;

    // get application specific global parameters
    configureModule(cfg);

    AnnouncePath = cfg.getParameter("announce_path",ANNOUNCE_PATH);
    if( !AnnouncePath.empty() 
	&& AnnouncePath[AnnouncePath.length()-1] != '/' )
	AnnouncePath += "/";

    AnnounceFile = cfg.getParameter("default_announce",ANNOUNCE_FILE);

    string announce_file = AnnouncePath + AnnounceFile;
    if(!file_exists(announce_file)){
	ERROR("default file for ann_b2b module does not exist ('%s').\n",
	      announce_file.c_str());
	return -1;
    }


	auth_realm = cfg.getParameter("auth_realm", "");
	auth_user  = cfg.getParameter("auth_user",  "");
	auth_pwd   = cfg.getParameter("auth_pwd", "");

    uac_auth_f = AmPlugIn::instance()->getFactory4Seh("uac_auth");
    DBG("uac_auth_f == 0x%.16lX\n",(unsigned long)uac_auth_f);

	dialer.set_dial(cfg.getParameter("dial_ruri","default ruri"),
					cfg.getParameter("dial_from","default from"),
					cfg.getParameter("dial_fromuri","default fromuri"),
					cfg.getParameter("dial_to","default to"));

	dialer.start();

    return 0;
}
Beispiel #25
0
int XMLRPC2DI::onLoad() {

  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
    return -1;

  string conf_xmlrpc_port = cfg.getParameter("xmlrpc_port",XMLRPC_PORT);
  if (conf_xmlrpc_port.empty()) {
    ERROR("configuration: xmlrpc_port must be defined!\n");
    return -1;
  } 
  
  if (str2i(conf_xmlrpc_port, XMLRPCPort)) {
    ERROR("configuration: unable to decode xmlrpc_port value '%s'!\n", 
	  conf_xmlrpc_port.c_str());
    return -1;
  }

  bool export_di = false;
  string direct_export = cfg.getParameter("direct_export","");
  if (direct_export.length()) {
    DBG("direct_export interfaces: %s\n", direct_export.c_str());
  } else {
    DBG("No direct_export interfaces.\n");
  }

  string export_di_s = cfg.getParameter("export_di","yes");
  if (export_di_s == "yes") {
    export_di = true;
  } 
  
  DBG("XMLRPC Server: %snabling builtin method 'di'.\n", export_di?"E":"Not e");


  server = new XMLRPC2DIServer(XMLRPCPort, export_di, direct_export);

  server->start();
  return 0;
}
int RegistrationAgentFactory::onLoad()
{
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
    return -1;

  // get application specific global parameters
  configureModule(cfg);

  int i = 0;
  string idx_str;
  do {
    RegInfo ri;
    ri.domain = cfg.getParameter(CFG_PARAM_DOMAIN+idx_str,"");
    ri.user = cfg.getParameter(CFG_PARAM_USER+idx_str,"");
    ri.display_name = cfg.getParameter(CFG_PARAM_DISPLAY+idx_str,"");
    ri.auth_user = cfg.getParameter(CFG_PARAM_AUTH+idx_str,"");
    ri.passwd = cfg.getParameter(CFG_PARAM_PASS+idx_str,"");
    ri.proxy = cfg.getParameter(CFG_PARAM_PROXY+idx_str,"");

    if (!ri.domain.length() || !ri.user.length()) {
      // not including the passwd: might be IP based registration
      // not including the display name: allow user to skip it
      DBG("no mandatory config parameters '" CFG_PARAM_DOMAIN "' and '"
        CFG_PARAM_USER "' provided for entry #%d; configuration halted.\n", i);
      break;
    }

    if (!ri.auth_user.length()) // easier to config
      ri.auth_user = ri.user;

    dialer.add_reg(ri);
    DBG("Adding registration account #%d (%s %s %s %s %s)\n", i, 
        ri.domain.c_str(), ri.user.c_str(), ri.display_name.c_str(), 
        ri.auth_user.c_str(), ri.proxy.c_str());

    i ++;
    idx_str = int2str(i);
  } while (i < MAX_ACCOUNTS);

  if (i <= 0) {
    ERROR("no complete account provided: '" MOD_NAME "' module remains "
        "inactive, which might not be what you want!\n");
  } else {
    dialer.start();
  }

  return 0;
}
Beispiel #27
0
void DSMFactory::loadDSM(const AmArg& args, AmArg& ret) {
  string dsm_name  = args.get(0).asCStr();

  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) {
      ret.push(500);
      ret.push("loading config file " +AmConfig::ModConfigPath + string(MOD_NAME ".conf"));
      return;
  }

  string DiagPath = cfg.getParameter("diag_path");
  if (DiagPath.length() && DiagPath[DiagPath.length()-1] != '/')
    DiagPath += '/';

  string ModPath = cfg.getParameter("mod_path");

  string dsm_file_name = DiagPath+dsm_name+".dsm";
  string res = "OK";

  ScriptConfigs_mut.lock();
  try {
    if (MainScriptConfig.diags->hasDiagram(dsm_name)) {
      ret.push(400);
      ret.push("DSM named '" + dsm_name + "' already loaded (use reloadDSMs to reload all)");
    } else {
      if (!MainScriptConfig.diags->loadFile(dsm_file_name, dsm_name, ModPath, DebugDSM)) {
	ret.push(500);
	ret.push("error loading "+dsm_name+" from "+ dsm_file_name);
      } else {
	ret.push(200);
	ret.push("loaded "+dsm_name+" from "+ dsm_file_name);
      }
    }
  } catch(...) {
    ScriptConfigs_mut.unlock();
    throw;
  }
  ScriptConfigs_mut.unlock();
}
Beispiel #28
0
int MOD_CLS_NAME::preload() {
   AmConfigReader cfg;
   if(cfg.loadPluginConf(MOD_NAME)) {
     INFO("no module configuration for '%s' found, not preloading regular expressions\n",
	  MOD_NAME);
     return 0;
   }

   bool failed = false;
   for (std::map<string,string>::const_iterator it =
	  cfg.begin(); it != cfg.end(); it++) {
     if (add_regex(it->first, it->second)) {
       ERROR("compiling regex '%s' for '%s'\n",
	     it->second.c_str(), it->first.c_str());
       failed = true;
     } else {
       DBG("compiled regex '%s' as '%s'\n", it->second.c_str(), it->first.c_str());
     }
   }

   return failed? -1 : 0;
}
Beispiel #29
0
static int readInterfaces(AmConfigReader& cfg)
{
  if(!cfg.hasParameter("interfaces")) {
    // no interface list defined:
    // read default params
    readSIPInterface(cfg,"");
    readRTPInterface(cfg,"");
    return 0;
  }

  vector<string> if_names;
  string ifs_str = cfg.getParameter("interfaces");
  if(ifs_str.empty()) {
    ERROR("empty interface list.\n");
    return -1;
  }

  if_names = explode(ifs_str,",");
  if(!if_names.size()) {
    ERROR("could not parse interface list.\n");
    return -1;
  }

  for(vector<string>::iterator it = if_names.begin();
      it != if_names.end(); it++) {

    readSIPInterface(cfg,*it);
    readRTPInterface(cfg,*it);

    if((AmConfig::SIP_If_names.find(*it) == AmConfig::SIP_If_names.end()) &&
       (AmConfig::RTP_If_names.find(*it) == AmConfig::RTP_If_names.end())) {
      ERROR("missing interface definition for '%s'\n",it->c_str());
      return -1;
    }
  }

  //TODO: check interfaces
  return 0;
}
int ServiceLineFactory::onLoad()
{
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
    return -1;

  // get application specific global parameters
  configureModule(cfg);

  AnnounceFile = cfg.getParameter("prompt",ANNOUNCE_FILE);
  DBG("Prompt = %s\n",AnnounceFile.c_str());

  string announce_file = AnnounceFile;
  if(!file_exists(announce_file)){
    ERROR("prompt file for serviceline module does not exist ('%s').\n",
	  announce_file.c_str());
    return -1;
  }

  DBG("ServiceLine Connect DTMF Key Mapping:\n");
  for (unsigned int i=0;i<10;i++) {
    callee_numbers[i] = cfg.getParameter("callee_number"+int2str(i));
    DBG("Key %u -> Extension __%s__\n", 
	i, callee_numbers[i].empty()?
	"none":callee_numbers[i].c_str());
  }
  
  GWDomain= cfg.getParameter("gw_domain", "");;
  GWUser= cfg.getParameter("gw_user", "");;
  GWDisplayname= cfg.getParameter("gw_displayname", "");;
  
  GWAuthuser= cfg.getParameter("gw_authuser", "");
  GWAuthrealm=cfg.getParameter("gw_authrealm", ""); // actually unused
  GWAuthpwd=cfg.getParameter("gw_authpwd", "");

  return 0;
}