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; }
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 RegistrationAgentFactory::onLoad() { AmConfigReader cfg; if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) return -1; // get application specific global parameters configureModule(cfg); // stay backwards compatible RegInfo ri; ri.domain = cfg.getParameter("domain",""); ri.user = cfg.getParameter("user",""); ri.display_name = cfg.getParameter("display_name",""); ri.auth_user = cfg.getParameter("auth_user",""); ri.passwd = cfg.getParameter("pwd",""); if (!ri.domain.length() || !ri.user.length() || !ri.display_name.length() || !ri.auth_user.length() || !ri.passwd.length()) { ERROR("Account for registration not correctly configured.\n"); ERROR("RegistrationAgent will not register any accounts.\n"); return 0; } DBG("Adding registration #%d (%s %s %s %s)\n", 0, ri.domain.c_str(), ri.user.c_str(), ri.display_name.c_str(), ri.auth_user.c_str()); dialer.add_reg(ri); unsigned int ri_index = 1; while (ri_index < 100) { RegInfo ri; ri.domain = cfg.getParameter("domain"+int2str(ri_index),""); ri.user = cfg.getParameter("user"+int2str(ri_index),""); ri.display_name = cfg.getParameter("display_name"+int2str(ri_index),""); ri.auth_user = cfg.getParameter("auth_user"+int2str(ri_index),""); ri.passwd = cfg.getParameter("pwd"+int2str(ri_index),""); if (!ri.domain.length() || !ri.user.length() || !ri.display_name.length() || !ri.auth_user.length() || !ri.passwd.length()) break; DBG("Adding registration #%d (%s %s %s %s)\n", ri_index, ri.domain.c_str(), ri.user.c_str(), ri.display_name.c_str(), ri.auth_user.c_str()); dialer.add_reg(ri); ri_index++; } dialer.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; }
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; }
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; }
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; }
int DSMFactory::onLoad() { if (loaded) return 0; loaded = true; AmConfigReader cfg; if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) return -1; // get application specific global parameters configureModule(cfg); DebugDSM = cfg.getParameter("debug_raw_dsm") == "yes"; if (!loadPrompts(cfg)) return -1; if (!loadPromptSets(cfg)) return -1; if (!loadDiags(cfg, MainScriptConfig.diags)) return -1; vector<string> registered_apps; if (!registerApps(cfg, MainScriptConfig.diags, registered_apps)) return -1; InboundStartDiag = cfg.getParameter("inbound_start_diag"); if (InboundStartDiag.empty()) { INFO("no 'inbound_start_diag' set in config. " "inbound calls with application 'dsm' disabled.\n"); } OutboundStartDiag = cfg.getParameter("outbound_start_diag"); if (OutboundStartDiag.empty()) { INFO("no 'outbound_start_diag' set in config. " "outbound calls with application 'dsm' disabled.\n"); } if (!InboundStartDiag.empty()) AmPlugIn::instance()->registerFactory4App("dsm",this); MainScriptConfig.config_vars.insert(cfg.begin(), cfg.end()); // for (std::map<string,string>::const_iterator it = // cfg.begin(); it != cfg.end(); it++) // MainScriptConfig.config_vars[it->first] = it->second; MainScriptConfig.RunInviteEvent = cfg.getParameter("run_invite_event")=="yes"; MainScriptConfig.SetParamVariables = cfg.getParameter("set_param_variables")=="yes"; #ifdef USE_MONITORING string monitoring_full_callgraph = cfg.getParameter("monitoring_full_stategraph"); MonitoringFullCallgraph = monitoring_full_callgraph == "yes"; DBG("%sogging full call graph (states) to monitoring.\n", MonitoringFullCallgraph?"L":"Not l"); string monitoring_full_transitions = cfg.getParameter("monitoring_full_transitions"); MonitoringFullTransitions = monitoring_full_transitions == "yes"; DBG("%sogging full call graph (transitions) to monitoring.\n", MonitoringFullTransitions?"L":"Not l"); string cfg_usecaller = cfg.getParameter("monitor_select_use_caller"); if (cfg_usecaller.empty() || cfg_usecaller=="from") MonSelectCaller = MonSelect_FROM; else if (cfg_usecaller=="no") MonSelectCaller = MonSelect_NONE; else if (cfg_usecaller=="pai") MonSelectCaller = MonSelect_PAI; else { ERROR("monitor_select_use_caller value '%s' not understood\n", cfg_usecaller.c_str()); } string cfg_usecallee = cfg.getParameter("monitor_select_use_callee"); if (cfg_usecallee.empty() || cfg_usecallee=="ruri") MonSelectCallee = MonSelect_RURI; else if (cfg_usecallee=="no") MonSelectCallee = MonSelect_NONE; else if (cfg_usecallee=="from") MonSelectCallee = MonSelect_FROM; else { ERROR("monitor_select_use_callee value '%s' not understood\n", cfg_usecallee.c_str()); } #endif string conf_d_dir = cfg.getParameter("conf_dir"); if (!conf_d_dir.empty()) { if (conf_d_dir[conf_d_dir.length()-1] != '/') conf_d_dir += '/'; DBG("processing configurations in '%s'...\n", conf_d_dir.c_str()); int err=0; struct dirent* entry; DIR* dir = opendir(conf_d_dir.c_str()); if(!dir){ ERROR("config loader (%s): %s\n", conf_d_dir.c_str(), strerror(errno)); return -1; } while( ((entry = readdir(dir)) != NULL) && (err == 0) ){ string conf_name = string(entry->d_name); if(conf_name.find(".conf",conf_name.length()-5) == string::npos ){ continue; } string conf_file_name = conf_d_dir + conf_name; DBG("loading %s ...\n",conf_file_name.c_str()); if (!loadConfig(conf_file_name, conf_name, false, NULL)) return -1; } closedir(dir); } return 0; }
int ConferenceFactory::onLoad() { AmConfigReader cfg; if(cfg.loadFile(AmConfig::ModConfigPath + string(APP_NAME)+ ".conf")) return -1; // get application specific global parameters configureModule(cfg); #ifdef USE_MYSQL /* Get default audio from MySQL */ string mysql_server, mysql_user, mysql_passwd, mysql_db; mysql_server = cfg.getParameter("mysql_server"); if (mysql_server.empty()) { mysql_server = "localhost"; } mysql_user = cfg.getParameter("mysql_user"); if (mysql_user.empty()) { ERROR("conference.conf parameter 'mysql_user' is missing.\n"); return -1; } mysql_passwd = cfg.getParameter("mysql_passwd"); if (mysql_passwd.empty()) { ERROR("conference.conf parameter 'mysql_passwd' is missing.\n"); return -1; } mysql_db = cfg.getParameter("mysql_db"); if (mysql_db.empty()) { mysql_db = "sems"; } try { #ifdef VERSION2 Connection.set_option(Connection.opt_reconnect, true); #else Connection.set_option(new mysqlpp::ReconnectOption(true)); #endif Connection.connect(mysql_db.c_str(), mysql_server.c_str(), mysql_user.c_str(), mysql_passwd.c_str()); if (!Connection) { ERROR("Database connection failed: %s\n", Connection.error()); return -1; } } catch (const mysqlpp::BadOption& er) { ERROR("MySQL++ set_option error: %s\n", er.what()); return -1; } catch (const mysqlpp::Exception& er) { // Catch-all for any MySQL++ exceptions ERROR("MySQL++ error: %s\n", er.what()); return -1; } if (!get_audio_file(LONELY_USER_MSG, "", "", LonelyUserFile)) { return -1; } if (LonelyUserFile.empty()) { ERROR("default announce 'first_participant_msg'\n"); ERROR("for module conference does not exist.\n"); return -1; } if (!get_audio_file(JOIN_SOUND, "", "", JoinSound)) { return -1; } if (!get_audio_file(DROP_SOUND, "", "", DropSound)) { return -1; } #else /* Get default audio from file system */ AudioPath = cfg.getParameter("audio_path", ANNOUNCE_PATH); LonelyUserFile = cfg.getParameter("default_announce"); if (LonelyUserFile.empty()) { LonelyUserFile = AudioPath + "/" ANNOUNCE_FILE; } else { if (LonelyUserFile[0] != '/') { LonelyUserFile = AudioPath + "/" + LonelyUserFile; } } if(!file_exists(LonelyUserFile)){ ERROR("default announce '%s' \n",LonelyUserFile.c_str()); ERROR("for module conference does not exist.\n"); return -1; } JoinSound = cfg.getParameter("join_sound"); if (!JoinSound.empty()) { if (JoinSound[0] != '/') { JoinSound = AudioPath + "/" + JoinSound; } } DropSound = cfg.getParameter("drop_sound"); if (!DropSound.empty()) { if (DropSound[0] != '/') { DropSound = AudioPath + "/" + DropSound; } } #endif DialoutSuffix = cfg.getParameter("dialout_suffix"); if(DialoutSuffix.empty()){ WARN("No dialout_suffix has been configured in the conference plug-in:\n"); WARN("\t -> dial out will not be available unless P-Dialout-Suffix\n"); WARN("\t -> header parameter is passed to conference plug-in\n"); } 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"); } MaxParticipants = 0; string max_participants = cfg.getParameter("max_participants"); if (max_participants.length() && str2i(max_participants, MaxParticipants)) { ERROR("while parsing max_participants parameter\n"); } UseRFC4240Rooms = cfg.getParameter("use_rfc4240_rooms")=="yes"; DBG("%ssing RFC4240 room naming.\n", UseRFC4240Rooms?"U":"Not u"); 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); #ifdef USE_MYSQL /* Get email templates from MySQL */ string mysql_server, mysql_user, mysql_passwd, mysql_db; mysql_server = cfg.getParameter("mysql_server"); if (mysql_server.empty()) { mysql_server = "localhost"; } mysql_user = cfg.getParameter("mysql_user"); if (mysql_user.empty()) { ERROR("voicemail.conf paramater 'mysql_user' is missing.\n"); return -1; } mysql_passwd = cfg.getParameter("mysql_passwd"); if (mysql_passwd.empty()) { ERROR("voicemail.conf paramater 'mysql_passwd' is missing.\n"); return -1; } mysql_db = cfg.getParameter("mysql_db"); if (mysql_db.empty()) { mysql_db = "sems"; } try { Connection.connect(mysql_db.c_str(), mysql_server.c_str(), mysql_user.c_str(), mysql_passwd.c_str()); if (!Connection) { ERROR("Database connection failed: %s\n", Connection.error()); return -1; } Connection.set_option(mysqlpp::Connection::opt_reconnect, true); } catch (const mysqlpp::Exception& er) { // Catch-all for any MySQL++ exceptions ERROR("MySQL++ error: %s\n", er.what()); return -1; } if(loadEmailTemplatesFromMySQL()){ ERROR("while loading email templates from MySQL\n"); return -1; } #else /* Get email templates from file system */ if(loadEmailTemplates(cfg.getParameter("email_template_path",DEFAULT_MAIL_TMPL_PATH))){ ERROR("while loading email templates\n"); return -1; } AnnouncePath = cfg.getParameter("announce_path",ANNOUNCE_PATH); DefaultAnnounce = cfg.getParameter("default_announce",DEFAULT_ANNOUNCE); #endif MaxRecordTime = cfg.getParameterInt("max_record_time",DEFAULT_RECORD_TIME); RecFileExt = cfg.getParameter("rec_file_ext",DEFAULT_AUDIO_EXT); UserTimer = AmPlugIn::instance()->getFactory4Di("user_timer"); if(!UserTimer){ ERROR("could not load user_timer from session_timer plug-in\n"); return -1; } EmailAddress = cfg.getParameter("email_address"); return 0; }
int WebConferenceFactory::onLoad() { // only execute this once if (configured) return 0; configured = true; 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, WEBCONF_ANNOUNCE_PATH "first_paricipant.wav"); AM_PROMPT_ADD(JOIN_SOUND, WEBCONF_ANNOUNCE_PATH "beep.wav"); AM_PROMPT_ADD(DROP_SOUND, WEBCONF_ANNOUNCE_PATH "beep.wav"); AM_PROMPT_ADD(ENTER_PIN, WEBCONF_ANNOUNCE_PATH "enter_pin.wav"); AM_PROMPT_ADD(WRONG_PIN, WEBCONF_ANNOUNCE_PATH "wrong_pin.wav"); AM_PROMPT_ADD(ENTERING_CONFERENCE, WEBCONF_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"); } string direct_room_re_str = cfg.getParameter("direct_room_re"); if (!direct_room_re_str.length()) { DBG("no direct room access prefixes set.\n"); } else { if (regcomp(&direct_room_re, direct_room_re_str.c_str(), REG_EXTENDED|REG_NOSUB)) { ERROR("unable to compile direct room RE '%s'.\n", direct_room_re_str.c_str()); return -1; } use_direct_room = true; string direct_room_strip_str = cfg.getParameter("direct_room_strip"); if (direct_room_strip_str.length() && str2i(direct_room_strip_str, direct_room_strip)) { ERROR("unable to decipher direct_room_strip amount '%s'\n", direct_room_strip_str.c_str()); return -1; } DBG("Webconference will strip %d leading characters from " "direct room access usernames\n", direct_room_strip); } string feedback_filename = cfg.getParameter("feedback_file"); if (!feedback_filename.empty()) { feedback_file.open(feedback_filename.c_str(), std::ios::out|std::ios::app); if (!feedback_file.good()) { ERROR("opening feedback file '%s'\n", feedback_filename.c_str()); } else { DBG("successfully opened feedback file '%s'\n", feedback_filename.c_str()); } } string stats_dir = cfg.getParameter("stats_dir"); if (stats_dir.empty()) DBG("call statistics will not be persistent across restart.\n"); stats = new WCCCallStats(stats_dir); urlbase = cfg.getParameter("webconference_urlbase"); if (urlbase.empty()) DBG("No urlbase set - SDP will not contain direct access URL.\n"); MasterPassword = cfg.getParameter("master_password"); if (!MasterPassword.empty()) { DBG("Master password set.\n"); } if (cfg.getParameter("participants_expire") == "no") { ParticipantExpiredDelay = -1; } else { // default: 10s ParticipantExpiredDelay = cfg.getParameterInt("participants_expire_delay", 10); } if (cfg.getParameter("rooms_expire") == "no") { RoomExpiredDelay = -1; } else { RoomExpiredDelay = cfg.getParameterInt("rooms_expire_delay", 7200); // default: 2h } // default: every 10 times RoomSweepInterval = cfg.getParameterInt("room_sweep_interval", 10); 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); // smtp_server SmtpServerAddress = cfg.getParameter("smtp_server",SmtpServerAddress); // smtp_port if(cfg.hasParameter("smtp_port")){ if(sscanf(cfg.getParameter("smtp_port").c_str(), "%u",&SmtpServerPort) != 1) { ERROR("invalid smtp_port specified\n"); return -1; } } DBG("SMTP server set to %s:%u\n", SmtpServerAddress.c_str(), SmtpServerPort); #ifdef USE_MYSQL /* Get email templates from MySQL */ string mysql_server, mysql_user, mysql_passwd, mysql_db; mysql_server = cfg.getParameter("mysql_server"); if (mysql_server.empty()) { mysql_server = "localhost"; } mysql_user = cfg.getParameter("mysql_user"); if (mysql_user.empty()) { ERROR("voicemail.conf paramater 'mysql_user' is missing.\n"); return -1; } mysql_passwd = cfg.getParameter("mysql_passwd"); if (mysql_passwd.empty()) { ERROR("voicemail.conf paramater 'mysql_passwd' is missing.\n"); return -1; } mysql_db = cfg.getParameter("mysql_db"); if (mysql_db.empty()) { mysql_db = "sems"; } try { Connection.connect(mysql_db.c_str(), mysql_server.c_str(), mysql_user.c_str(), mysql_passwd.c_str()); if (!Connection) { ERROR("Database connection failed: %s\n", Connection.error()); return -1; } Connection.set_option(mysqlpp::Connection::opt_reconnect, true); } catch (const mysqlpp::Exception& er) { // Catch-all for any MySQL++ exceptions ERROR("MySQL++ error: %s\n", er.what()); return -1; } if(loadEmailTemplatesFromMySQL()){ ERROR("while loading email templates from MySQL\n"); return -1; } #else /* Get email templates from file system */ if(loadEmailTemplates(cfg.getParameter("email_template_path", DEFAULT_MAIL_TMPL_PATH))){ ERROR("while loading email templates\n"); return -1; } AnnouncePath = cfg.getParameter("announce_path"); DefaultAnnounce = cfg.getParameter("default_announce"); #endif MaxRecordTime = cfg.getParameterInt("max_record_time",DEFAULT_RECORD_TIME); RecFileExt = cfg.getParameter("rec_file_ext",DEFAULT_AUDIO_EXT); UserTimer = AmPlugIn::instance()->getFactory4Di("user_timer"); if(!UserTimer){ ERROR("could not load user_timer from session_timer plug-in\n"); return -1; } MessageStorage = NULL; MessageStorage = AmPlugIn::instance()->getFactory4Di("msg_storage"); if(NULL == MessageStorage){ INFO("could not load msg_storage. Voice Box mode will not be available.\n"); } else { if ((msg_storage = MessageStorage->getInstance()) == NULL) { ERROR("getting msg_storage instance\n"); return -1; } } TryPersonalGreeting = cfg.getParameter("try_personal_greeting") == "yes"; DBG("voicemail will %stry to find a personal greeting.\n", TryPersonalGreeting?"":"not "); DBG("Starting SMTP daemon\n"); AmMailDeamon::instance()->start(); string s_save_empty_msg = cfg.getParameter("box_save_empty_msg"); if (!s_save_empty_msg.empty()) { SaveEmptyMsg = !(s_save_empty_msg == "no"); } DBG("Voicebox will%s save empty messages.\n", SaveEmptyMsg?"":" not"); return 0; }
int WebConferenceFactory::onLoad() { // only execute this once if (configured) return 0; configured = true; 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, WEBCONF_ANNOUNCE_PATH "first_paricipant.wav"); AM_PROMPT_ADD(JOIN_SOUND, WEBCONF_ANNOUNCE_PATH "beep.wav"); AM_PROMPT_ADD(DROP_SOUND, WEBCONF_ANNOUNCE_PATH "beep.wav"); AM_PROMPT_ADD(ENTER_PIN, WEBCONF_ANNOUNCE_PATH "enter_pin.wav"); AM_PROMPT_ADD(WRONG_PIN, WEBCONF_ANNOUNCE_PATH "wrong_pin.wav"); AM_PROMPT_ADD(ENTERING_CONFERENCE, WEBCONF_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"); } string direct_room_re_str = cfg.getParameter("direct_room_re"); if (!direct_room_re_str.length()) { DBG("no direct room access prefixes set.\n"); } else { if (regcomp(&direct_room_re, direct_room_re_str.c_str(), REG_EXTENDED|REG_NOSUB)) { ERROR("unable to compile direct room RE '%s'.\n", direct_room_re_str.c_str()); return -1; } use_direct_room = true; string direct_room_strip_str = cfg.getParameter("direct_room_strip"); if (direct_room_strip_str.length() && str2i(direct_room_strip_str, direct_room_strip)) { ERROR("unable to decipher direct_room_strip amount '%s'\n", direct_room_strip_str.c_str()); return -1; } DBG("Webconference will strip %d leading characters from " "direct room access usernames\n", direct_room_strip); } string feedback_filename = cfg.getParameter("feedback_file"); if (!feedback_filename.empty()) { feedback_file.open(feedback_filename.c_str(), std::ios::out); if (!feedback_file.good()) { ERROR("opening feedback file '%s'\n", feedback_filename.c_str()); } else { DBG("successfully opened feedback file '%s'\n", feedback_filename.c_str()); } } return 0; }
void vTaskSI (void* pvParameters) { (void) pvParameters; portTickType xLastWakeTime; Module *entryDist, *asservPosDist, *asservVitDist, *measureDerivatorDist, *imeInIntegratorDist; Module *entryRot, *asservPosRot, *asservVitRot, *measureDerivatorRot, *imeInIntegratorRot; Module *ifaceMERight, *ifaceMELeft, *starter, *operatorIn, *operatorOut, *toggleSwitchLeft, *toggleSwitchRight; EntryConfig entryConfigDist, entryConfigRot; // Enregistrement de l'asservissement en distance ModuleValue posKpDist = 50; ModuleValue posKiDist = 0; ModuleValue posKdDist = 5; // ModuleValue derivDist = 16000; ModuleValue vitKpDist = 1000; ModuleValue vitKiDist = 0; ModuleValue vitKdDist = 15; // ModuleValue accelDist = 500; // ModuleValue commandDist = 2000; entryConfigDist.nbEntry = 9; entryConfigDist.value[0] = &posKpDist; // kp entryConfigDist.value[1] = &posKiDist; // ki entryConfigDist.value[2] = &posKdDist; // kd entryConfigDist.value[3] = &(trajDist.vit); // deriv entryConfigDist.value[4] = &vitKpDist; // kp entryConfigDist.value[5] = &vitKiDist; // ki entryConfigDist.value[6] = &vitKdDist; // kd entryConfigDist.value[7] = &(trajDist.acc); // accel entryConfigDist.value[8] = &(trajDist.pos); // command // Enregistrement de l'asservissement en rotation ModuleValue posKpRot = 50; ModuleValue posKiRot = 3; ModuleValue posKdRot = 15; // ModuleValue derivRot = 8000; ModuleValue vitKpRot = 1000; ModuleValue vitKiRot = 0; ModuleValue vitKdRot = 20; // ModuleValue accelRot = 1000; // ModuleValue commandRot = 200; // (200, -300) = max(command) entryConfigRot.nbEntry = 9; entryConfigRot.value[0] = &posKpRot; // kp entryConfigRot.value[1] = &posKiRot; // ki entryConfigRot.value[2] = &posKdRot; // kd entryConfigRot.value[3] = &(trajRot.vit); // deriv entryConfigRot.value[4] = &vitKpRot; // kp entryConfigRot.value[5] = &vitKiRot; // ki entryConfigRot.value[6] = &vitKdRot; // kd entryConfigRot.value[7] = &(trajRot.acc); // accel entryConfigRot.value[8] = &(trajRot.pos); // command // On ajoute un interupteur à notre shéma bloc // qui empéche l'asserv de s'effectuer quand le pontH n'est pas alimenté EFBclearBit (DDR_HBRIDGE_ON, BIT_HBRIDGE_ON); ToggleSwitchConfig toggleSwitchConfig; toggleSwitchConfig.value = (uint8_t*) &(PORT_HBRIDGE_ON); toggleSwitchConfig.mask = _BV (BIT_HBRIDGE_ON); toggleSwitchConfig.off = TOGGLE_ON; xLastWakeTime = taskGetTickCount (); // Création du Starter starter = initModule(&ctlBlock, 1, 0, starterType, 0); if (starter == 0) { return; } // Création de l'interface systeme (IfaceMERight) ifaceMERight = initModule(&ctlBlock, 1, 2, ifaceMEType, 1); if (ifaceMERight == 0) { return; } // Création de l'interface systeme (IfaceMELeft) ifaceMELeft = initModule(&ctlBlock, 1, 2, ifaceMEType, 0); if (ifaceMELeft == 0) { return; } // Création de l'operateur asservs -> IMEs operatorIn = initModule(&ctlBlock, 2, 2, operatorType, 1); if (operatorIn == 0) { return; } // Création de l'operateur IMEs -> asservs operatorOut = initModule(&ctlBlock, 2, 2, operatorType, 0); if (operatorOut == 0) { return; } toggleSwitchRight = initModule(&ctlBlock, 1, 1, toggleSwitchType, 0); if (toggleSwitchRight == 0) { return; } toggleSwitchLeft = initModule(&ctlBlock, 1, 1, toggleSwitchType, 0); if (toggleSwitchLeft == 0) { return; } // Création de l'Entry entryDist = initModule(&ctlBlock, 0, entryConfigDist.nbEntry, entryType, 0); if (entryDist == 0) { return; } asservPosDist = initModule(&ctlBlock, 6, 1, asservType, 0); if (asservPosDist == 0) { return; } asservVitDist = initModule(&ctlBlock, 6, 1, asservType, 0); if (asservVitDist == 0) { return; } measureDerivatorDist = initModule(&ctlBlock, 1, 1, derivatorType, 0); if (measureDerivatorDist == 0) { return; } imeInIntegratorDist = initModule(&ctlBlock, 1, 1, integratorType, 0); if (imeInIntegratorDist == 0) { return; } // Création de l'Entry entryRot = initModule(&ctlBlock, 0, entryConfigRot.nbEntry, entryType, 0); if (entryRot == 0) { return; } asservPosRot = initModule(&ctlBlock, 6, 1, asservType, 0); if (asservPosRot == 0) { return; } asservVitRot = initModule(&ctlBlock, 6, 1, asservType, 0); if (asservVitRot == 0) { return; } measureDerivatorRot = initModule(&ctlBlock, 1, 1, derivatorType, 0); if (measureDerivatorRot == 0) { return; } imeInIntegratorRot = initModule(&ctlBlock, 1, 1, integratorType, 0); if (imeInIntegratorRot == 0) { return; } debug("H"); if (createSystem(&ctlBlock, starter , 50) == ERR_TIMER_NOT_DEF) { return; } // debug("oii: %l %l\r\n", (uint32_t)getInput(parent, 0), (uint32_t)getInput(parent, 1)); // debug("cp\r\n"); if (configureModule(starter, NULL) != NO_ERR) { return; } if (configureModule(ifaceMELeft, (void*)&imes[0]) != NO_ERR) { return; } if (configureModule(ifaceMERight, (void*)&imes[1]) != NO_ERR) { return; } if (configureModule(operatorIn, (void*)funCalcValueForMotor) != NO_ERR) { return; } if (configureModule(operatorOut, (void*)funCalcValueForAsserv) != NO_ERR) { return; } if (configureModule(toggleSwitchRight, (void*)&toggleSwitchConfig) != NO_ERR) { return; } debug("E"); if (configureModule(toggleSwitchLeft, (void*)&toggleSwitchConfig) != NO_ERR) { return; } debug("E"); if (configureModule(entryDist, (void*)&entryConfigDist) != NO_ERR) { return; } if (configureModule(asservPosDist, NULL) != NO_ERR) { return; } if (configureModule(asservVitDist, NULL) != NO_ERR) { return; } if (configureModule(measureDerivatorDist, NULL) != NO_ERR) { return; } if (configureModule(imeInIntegratorDist, NULL) != NO_ERR) { return; } if (configureModule(entryRot, (void*)&entryConfigRot) != NO_ERR) { return; } if (configureModule(asservPosRot, NULL) != NO_ERR) { return; } if (configureModule(asservVitRot, NULL) != NO_ERR) { return; } if (configureModule(measureDerivatorRot, NULL) != NO_ERR) { return; } if (configureModule(imeInIntegratorRot, NULL) != NO_ERR) { return; } debug("E"); // DISTANCE linkModuleWithInput(entryDist, 8, asservPosDist, AsservCommand); linkModuleWithInput(entryDist, 0, asservPosDist, AsservKp); linkModuleWithInput(entryDist, 1, asservPosDist, AsservKi); linkModuleWithInput(entryDist, 2, asservPosDist, AsservKd); linkModuleWithInput(entryDist, 3, asservPosDist, AsservDeriv); linkModuleWithInput(operatorOut, 0, asservPosDist, AsservMeasure); linkModuleWithInput(asservPosDist, 0, asservVitDist, AsservCommand); linkModuleWithInput(entryDist, 4, asservVitDist, AsservKp); linkModuleWithInput(entryDist, 5, asservVitDist, AsservKi); linkModuleWithInput(entryDist, 6, asservVitDist, AsservKd); linkModuleWithInput(entryDist, 7, asservVitDist, AsservDeriv); linkModuleWithInput(operatorOut, 0, measureDerivatorDist, 0); linkModuleWithInput(measureDerivatorDist, 0, asservVitDist, AsservMeasure); linkModuleWithInput(asservVitDist, 0, imeInIntegratorDist, 0); linkModuleWithInput(imeInIntegratorDist, 0, operatorIn, 0); // ROTATION linkModuleWithInput(entryRot, 8, asservPosRot, AsservCommand); linkModuleWithInput(entryRot, 0, asservPosRot, AsservKp); linkModuleWithInput(entryRot, 1, asservPosRot, AsservKi); linkModuleWithInput(entryRot, 2, asservPosRot, AsservKd); linkModuleWithInput(entryRot, 3, asservPosRot, AsservDeriv); linkModuleWithInput(operatorOut, 1, asservPosRot, AsservMeasure); linkModuleWithInput(asservPosRot, 0, asservVitRot, AsservCommand); linkModuleWithInput(entryRot, 4, asservVitRot, AsservKp); linkModuleWithInput(entryRot, 5, asservVitRot, AsservKi); linkModuleWithInput(entryRot, 6, asservVitRot, AsservKd); linkModuleWithInput(entryRot, 7, asservVitRot, AsservDeriv); linkModuleWithInput(operatorOut, 1, measureDerivatorRot, 0); linkModuleWithInput(measureDerivatorRot, 0, asservVitRot, AsservMeasure); linkModuleWithInput(asservVitRot, 0, imeInIntegratorRot, 0); linkModuleWithInput(imeInIntegratorRot, 0, operatorIn, 1); linkModuleWithInput(operatorIn, 1, ifaceMERight, 0); linkModuleWithInput(operatorIn, 0, ifaceMELeft, 0); // linkModuleWithInput(toggleSwitchRight, 0, ifaceMERight, 0); // linkModuleWithInput(toggleSwitchLeft, 0, ifaceMELeft, 0); linkModuleWithInput(ifaceMERight, 0, operatorOut, 1); linkModuleWithInput(ifaceMELeft, 0, operatorOut, 0); // linkModuleWithInput(ifaceMERight, 0, starter, 1); linkModuleWithInput(ifaceMELeft, 0, starter, 0); debug("E"); //resetSystem(&ctlBlock, portMAX_DELAY); for (;;) { if (startSystem(&ctlBlock) == NO_ERR) { if(waitEndOfSystem(&ctlBlock, 10000) == NO_ERR) { //resetSystem(&ctlBlock, portMAX_DELAY); //command += 500; } } // Cette fonction permet à la tache d'être périodique. // La tache est bloquée pendant (500ms - son temps d'execution). vTaskDelayUntil(&xLastWakeTime, 500/portTICK_RATE_MS); }
int DSMFactory::onLoad() { if (loaded) return 0; loaded = true; AmConfigReader cfg; if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) return -1; // get application specific global parameters configureModule(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()); } } } } 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; } string DiagPath = cfg.getParameter("diag_path"); if (DiagPath.length() && DiagPath[DiagPath.length()-1] != '/') DiagPath += '/'; string ModPath = cfg.getParameter("mod_path"); string preload_mods = cfg.getParameter("preload_mods"); vector<string> preload_names = explode(preload_mods, ","); if (preload_names.size()) { DSMChartReader reader; for (vector<string>::iterator it= preload_names.begin(); it != preload_names.end(); it++) { DBG("preloading '%s'...\n", it->c_str()); if (!reader.importModule("import("+*it+")", ModPath)) { ERROR("importing module '%s' for preload\n", it->c_str()); return -1; } DSMModule* last_loaded = reader.mods.back(); if (last_loaded) { if (last_loaded->preload()) { DBG("Error while preloading '%s'\n", it->c_str()); return -1; } } } } // 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 (!diags.loadFile(DiagPath+*it+".dsm", *it, ModPath)) { ERROR("loading %s from %s\n", it->c_str(), (DiagPath+*it+".dsm").c_str()); return -1; } } InboundStartDiag = cfg.getParameter("inbound_start_diag"); if (InboundStartDiag.empty()) { INFO("no 'inbound_start_diag' set in config. inbound calls disabled.\n"); } OutboundStartDiag = cfg.getParameter("outbound_start_diag"); if (OutboundStartDiag.empty()) { INFO("no 'outbound_start_diag' set in config. outbound calls disabled.\n"); } for (std::map<string,string>::const_iterator it = cfg.begin(); it != cfg.end(); it++) config[it->first] = it->second; RunInviteEvent = cfg.getParameter("run_invite_event")=="yes"; return 0; }
int EarlyAnnounceFactory::onLoad() { AmConfigReader cfg; if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) return -1; // get application specific global parameters configureModule(cfg); if (cfg.hasParameter("continue_b2b")) { if (cfg.getParameter("continue_b2b") == "yes") { ContinueB2B = Always; DBG("early_announce in b2bua mode.\n"); } else if (cfg.getParameter("continue_b2b") == "app-param") { ContinueB2B = AppParam; DBG("early_announce in b2bua/final reply mode " "(depends on app-param).\n"); } else { DBG("early_announce sends final reply.\n"); } } #ifdef USE_MYSQL /* Get default audio from MySQL */ string mysql_server, mysql_user, mysql_passwd, mysql_db; mysql_server = cfg.getParameter("mysql_server"); if (mysql_server.empty()) { mysql_server = "localhost"; } mysql_user = cfg.getParameter("mysql_user"); if (mysql_user.empty()) { ERROR("conference.conf paramater 'mysql_user' is missing.\n"); return -1; } mysql_passwd = cfg.getParameter("mysql_passwd"); if (mysql_passwd.empty()) { ERROR("conference.conf paramater 'mysql_passwd' is missing.\n"); return -1; } mysql_db = cfg.getParameter("mysql_db"); if (mysql_db.empty()) { mysql_db = "sems"; } AnnounceApplication = cfg.getParameter("application"); if (AnnounceApplication.empty()) { AnnounceApplication = MOD_NAME; } AnnounceMessage = cfg.getParameter("message"); if (AnnounceMessage.empty()) { AnnounceMessage = "greeting_msg"; } DefaultLanguage = cfg.getParameter("default_language"); if (DefaultLanguage.empty()) { DefaultLanguage = "en"; } try { #ifdef VERSION2 Connection.set_option(Connection.opt_reconnect, true); #else Connection.set_option(new mysqlpp::ReconnectOption(true)); #endif Connection.connect(mysql_db.c_str(), mysql_server.c_str(), mysql_user.c_str(), mysql_passwd.c_str()); if (!Connection) { ERROR("Database connection failed: %s\n", Connection.error()); return -1; } } catch (const mysqlpp::BadOption& er) { ERROR("MySQL++ set_option error: %s\n", er.what()); return -1; } catch (const mysqlpp::Exception& er) { // Catch-all for any MySQL++ exceptions ERROR("MySQL++ error: %s\n", er.what()); return -1; } string announce_file; if (!get_announce_msg(AnnounceApplication, AnnounceMessage, "", "", DefaultLanguage, &announce_file)) { return -1; } if (announce_file.empty()) { ERROR("default announce for " MOD_NAME " module does not exist.\n"); return -1; } #else /* Get default audio from file system */ 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 " MOD_NAME " module does not exist ('%s').\n", announce_file.c_str()); return -1; } #endif return 0; }
int CallBackFactory::onLoad() { AmConfigReader cfg; if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME)+ ".conf")) return -1; // get application specific global parameters configureModule(cfg); // get prompts AM_PROMPT_START; AM_PROMPT_ADD(WELCOME_PROMPT, WELCOME_PROMPT ".wav"); AM_PROMPT_END(prompts, cfg, MOD_NAME); string DigitsDir = cfg.getParameter("digits_dir"); if (DigitsDir.length() && DigitsDir[DigitsDir.length()-1]!='/') DigitsDir+='/'; if (!DigitsDir.length()) { ERROR("No digits_dir specified in configuration.\n"); } for (int i=0;i<10;i++) prompts.setPrompt(int2str(i), DigitsDir+int2str(i)+".wav", MOD_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"); } string accept_caller_re_str = cfg.getParameter(ACCEPT_CALLER_RE); if (!accept_caller_re_str.length()) { ERROR("no '" ACCEPT_CALLER_RE "' set.\n"); return -1; } else { if (regcomp(&accept_caller_re, accept_caller_re_str.c_str(), REG_EXTENDED|REG_NOSUB)) { ERROR("unable to compile caller RE '%s'.\n", accept_caller_re_str.c_str()); return -1; } } gw_user = cfg.getParameter("gw_user"); if (!gw_user.length()) { ERROR("need gw_user configured!\n"); return -1; } gw_domain = cfg.getParameter("gw_domain"); if (!gw_domain.length()) { ERROR("need gw_domain configured!\n"); return -1; } auth_user = cfg.getParameter("auth_user"); if (!auth_user.length()) auth_user = gw_user; // default to user auth_pwd = cfg.getParameter("auth_pwd"); if (!auth_pwd.length()) { ERROR("need auth_pwd configured!\n"); return -1; } cb_wait = cfg.getParameterInt("cb_wait", 5); DBG("cb_wait set to %d\n", cb_wait); DBG("starting callback thread. (%ld)\n", (long)this); start(); return 0; }
int DSMFactory::onLoad() { if (loaded) return 0; loaded = true; if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) return -1; // get application specific global parameters configureModule(cfg); DebugDSM = cfg.getParameter("debug_raw_dsm") == "yes"; CheckDSM = cfg.getParameter("dsm_consistency_check", "yes") == "yes"; if (!loadPrompts(cfg)) return -1; if (!loadPromptSets(cfg)) return -1; if (!loadDiags(cfg, MainScriptConfig.diags)) return -1; vector<string> registered_apps; if (!registerApps(cfg, MainScriptConfig.diags, registered_apps)) return -1; InboundStartDiag = cfg.getParameter("inbound_start_diag"); if (InboundStartDiag.empty()) { INFO("no 'inbound_start_diag' set in config. " "inbound calls with application 'dsm' disabled.\n"); } OutboundStartDiag = cfg.getParameter("outbound_start_diag"); if (OutboundStartDiag.empty()) { INFO("no 'outbound_start_diag' set in config. " "outbound calls with application 'dsm' disabled.\n"); } if (!InboundStartDiag.empty()) AmPlugIn::instance()->registerFactory4App("dsm",this); MainScriptConfig.config_vars.insert(cfg.begin(), cfg.end()); // for (std::map<string,string>::const_iterator it = // cfg.begin(); it != cfg.end(); it++) // MainScriptConfig.config_vars[it->first] = it->second; MainScriptConfig.RunInviteEvent = cfg.getParameter("run_invite_event")=="yes"; MainScriptConfig.SetParamVariables = cfg.getParameter("set_param_variables")=="yes"; vector<string> system_dsms = explode(cfg.getParameter("run_system_dsms"), ","); for (vector<string>::iterator it=system_dsms.begin(); it != system_dsms.end(); it++) { string status; if (createSystemDSM("main", *it, false /* reload */, status)) { DBG("created SystemDSM '%s'\n", it->c_str()); } else { ERROR("creating system DSM '%s': '%s'\n", it->c_str(), status.c_str()); return -1; } } #ifdef USE_MONITORING string monitoring_full_callgraph = cfg.getParameter("monitoring_full_stategraph"); MonitoringFullCallgraph = monitoring_full_callgraph == "yes"; DBG("%sogging full call graph (states) to monitoring.\n", MonitoringFullCallgraph?"L":"Not l"); string monitoring_full_transitions = cfg.getParameter("monitoring_full_transitions"); MonitoringFullTransitions = monitoring_full_transitions == "yes"; DBG("%sogging full call graph (transitions) to monitoring.\n", MonitoringFullTransitions?"L":"Not l"); string cfg_usecaller = cfg.getParameter("monitor_select_use_caller"); if (cfg_usecaller.empty() || cfg_usecaller=="from") MonSelectCaller = MonSelect_FROM; else if (cfg_usecaller=="no") MonSelectCaller = MonSelect_NONE; else if (cfg_usecaller=="pai") MonSelectCaller = MonSelect_PAI; else { ERROR("monitor_select_use_caller value '%s' not understood\n", cfg_usecaller.c_str()); } string cfg_usecallee = cfg.getParameter("monitor_select_use_callee"); if (cfg_usecallee.empty() || cfg_usecallee=="ruri") MonSelectCallee = MonSelect_RURI; else if (cfg_usecallee=="no") MonSelectCallee = MonSelect_NONE; else if (cfg_usecallee=="from") MonSelectCallee = MonSelect_FROM; else { ERROR("monitor_select_use_callee value '%s' not understood\n", cfg_usecallee.c_str()); } MonSelectFilters = explode(cfg.getParameter("monitor_select_filters"), ","); string filters; for (vector<string>::iterator it = MonSelectFilters.begin(); it != MonSelectFilters.end(); it++) { if (it != MonSelectFilters.begin()) filters += ", "; filters+=*it; } if (MonSelectFilters.size()) { DBG("using additional monitor app select filters: %s\n", filters.c_str()); } else { DBG("not using additional monitor app select filters\n"); } MonSelectFallback = cfg.getParameter("monitor_select_fallback"); #endif string conf_d_dir = cfg.getParameter("conf_dir"); if (!conf_d_dir.empty()) { if (conf_d_dir[conf_d_dir.length()-1] != '/') conf_d_dir += '/'; DBG("processing configurations in '%s'...\n", conf_d_dir.c_str()); int err=0; struct dirent* entry; DIR* dir = opendir(conf_d_dir.c_str()); if(!dir){ INFO("DSM config files loader (%s): %s\n", conf_d_dir.c_str(), strerror(errno)); } else { while( ((entry = readdir(dir)) != NULL) && (err == 0) ){ string conf_name = string(entry->d_name); if (conf_name.find(".conf",conf_name.length()-5) == string::npos){ continue; } string conf_file_name = conf_d_dir + conf_name; DBG("loading %s ...\n",conf_file_name.c_str()); if (!loadConfig(conf_file_name, conf_name, false, NULL)) return -1; } closedir(dir); } } if(cfg.hasParameter("enable_session_timer") && (cfg.getParameter("enable_session_timer") == string("yes")) ){ DBG("enabling session timers\n"); session_timer_f = AmPlugIn::instance()->getFactory4Seh("session_timer"); if(session_timer_f == NULL){ ERROR("Could not load the session_timer module: disabling session timers.\n"); } } return 0; }