本文整理汇总了C++中AmConfigReader::getParameter方法的典型用法代码示例。如果您正苦于以下问题:C++ AmConfigReader::getParameter方法的具体用法?C++ AmConfigReader::getParameter怎么用?C++ AmConfigReader::getParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AmConfigReader
的用法示例。
在下文中一共展示了AmConfigReader::getParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadPromptSets
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;
}
示例2: readFromConfig
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;
}
示例3: onLoad
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;
}
示例4: loadDiags
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;
}
示例5: onLoad
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;
}
示例6: readFilter
/** @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;
}
示例7: init
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;
}
示例8: onLoad
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;
}
示例9: onLoad
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;
}
示例10: onLoad
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;
}
示例11: readRTPInterface
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);
}
示例12: DBG
int XMLRPC2DI::load() {
if (configured) // load only once
return 0;
configured = true;
AmConfigReader cfg;
if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
return -1;
ServerRetryAfter = cfg.getParameterInt("server_retry_after", 10);
DBG("retrying failed server after %u seconds\n", ServerRetryAfter);
string run_server = cfg.getParameter("run_server","yes");
if (run_server != "yes") {
DBG("XMLRPC server will not be started.\n");
return 0;
}
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;
}
示例13: onLoad
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;
};
示例14: onLoad
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;
}
示例15: onLoad
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;
}