application.
* Simplified conference application by removing caching of audio
from MySQL to file system.
git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@343 8eb893ce-cfd4-0310-b710-fb5ebe64c474
query_string="select audio from "+string(DEFAULT_AUDIO_TABLE)+" where application='"+APP_NAME+"' and message='"+message+"' and language is null";
}else{
*audio_file="/tmp/"+domain+"_"+APP_NAME+"_"+
message+".wav";
query_string="select audio from "+string(DOMAIN_AUDIO_TABLE)+" where application='"+APP_NAME+"' and message='"+message+"' and domain='"+domain+"' and language is null";
query_string="select audio from "+string(DEFAULT_AUDIO_TABLE)+" where application='"+APP_NAME+"' and message='"+message+"' and language='"+language+"'";
}else{
*audio_file="/tmp/"+domain+"_"+APP_NAME+"_"+
message+"_"+language+".wav";
query_string="select audio from "+string(DOMAIN_AUDIO_TABLE)+" where application='"+APP_NAME+"' and message='"+message+"' and domain='"+domain+"' and language='"+language+"'";
query_string="select audio from "+string(USER_AUDIO_TABLE)+" where application='"+MOD_NAME+"' and message='"+message+"' and domain='"+domain+"' and userid='"+user+"'";
}else{
if(language.empty()){
if(domain.empty()){
*audio_file=string("/tmp/")+MOD_NAME+"_"+message+
".wav";
query_string="select audio from "+string(DEFAULT_AUDIO_TABLE)+" where application='"+MOD_NAME+"' and message='"+message+"' and language is null";
}else{
*audio_file=string("/tmp/")+domain+"_"+MOD_NAME+
"_"+message+".wav";
query_string="select audio from "+string(DOMAIN_AUDIO_TABLE)+" where application='"+MOD_NAME+"' and message='"+message+"' and domain='"+domain+"' and language is null";
}
}else{
if(domain.empty()){
*audio_file=string("/tmp/")+MOD_NAME+"_"+message+
"_"+language+".wav";
query_string="select audio from "+string(DEFAULT_AUDIO_TABLE)+" where application='"+MOD_NAME+"' and message='"+message+"' and language='"+language+"'";
query_string="select audio from "+string(DOMAIN_AUDIO_TABLE)+" where application='"+MOD_NAME+"' and message='"+message+"' and domain='"+domain+"' and language='"+language+"'";
query_string="select replace(template, '\r', '') as template, language from "+string(DEFAULT_TEMPLATE_TABLE)+" where application='"+MOD_NAME+"' and message='"+EMAIL_TMPL+"'";
DBG("Query string <%s>\n",query_string.c_str());
query<<query_string;
mysqlpp::Resultres=query.store();
mysqlpp::Row::size_typei;
mysqlpp::Row::size_typerow_count=res.num_rows();
mysqlpp::Rowrow;
for(i=0;i<row_count;i++){
row=res.at(i);
FILE*file;
unsignedlonglength=row["template"].size();
stringtmp_file,tmpl_name;
row=res.at(i);
if(string(row["language"])=="NULL"){
tmp_file="/tmp/voicemail_email.template";
tmpl_name=DEFAULT_MAIL_TMPL;
}else{
tmp_file=string("/tmp/voicemail_email_")+
string(row["language"])+".template";
tmpl_name=DEFAULT_MAIL_TMPL+"_"+
string(row["language"]);
}
file=fopen(tmp_file.c_str(),"wb");
fwrite(row["template"],1,length,file);
fclose(file);
DBG("loading %s as %s ...\n",tmp_file.c_str(),tmpl_name.c_str());
EmailTemplatetmp_tmpl;
if(tmp_tmpl.load(tmp_file)){
ERROR("Voicemail: could not load default"
" email template: '%s'\n",tmp_file.c_str());
return-1;
}else{
email_tmpl[tmpl_name]=tmp_tmpl;
}
}
if(email_tmpl.count(DEFAULT_MAIL_TMPL)==0){
ERROR("Voicemail: default email template does not exist\n");
return-1;
}
query_string="select domain, replace(template, '\r', '') as template, language from "+string(DOMAIN_TEMPLATE_TABLE)+" where application='"+MOD_NAME+"' and message='"+EMAIL_TMPL+"'";
DBG("Query string <%s>\n",query_string.c_str());
query<<query_string;
res=query.store();
row_count=res.num_rows();
for(i=0;i<row_count;i++){
row=res.at(i);
FILE*file;
unsignedlonglength=row["template"].size();
stringtmp_file,tmpl_name;
row=res.at(i);
if(string(row["language"])=="NULL"){
tmp_file="/tmp/"+string(row["domain"])+
"_voicemail_email.template";
tmpl_name=string(row["domain"]);
}else{
tmp_file=string("/tmp/")+string(row["domain"])+
"_voicemail_email_"+string(row["language"])+
".template";
tmpl_name=string(row["domain"])+"_"+
string(row["language"]);
}
file=fopen(tmp_file.c_str(),"wb");
fwrite(row["template"],1,length,file);
fclose(file);
DBG("loading %s as %s ...\n",tmp_file.c_str(),tmpl_name.c_str());