Blob Blame History Raw
From: Rick Barenthin <rb@terralink.de>
Date: Thu, 18 May 2017 14:43:33 +0200
Subject: [PATCH] apps: c++11 fixes for CMake and some apps


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 71cacc56..5e03d8ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -259,7 +259,7 @@ IF(CMAKE_COMPILER_IS_GNUCC)
 ENDIF(CMAKE_COMPILER_IS_GNUCC)
 
 IF(CMAKE_COMPILER_IS_GNUCXX)
-	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_THREAD_SAFE -D_REENTRANT -Wall -Wno-reorder -fPIC -g -O2")
+	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_THREAD_SAFE -D_REENTRANT -Wall -Wno-reorder -fPIC -std=c++11 -g -O2")
 ENDIF(CMAKE_COMPILER_IS_GNUCXX)
 
 SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
diff --git a/apps/conference/Conference.cpp b/apps/conference/Conference.cpp
index 7f9a025a..6650b635 100644
--- a/apps/conference/Conference.cpp
+++ b/apps/conference/Conference.cpp
@@ -19,8 +19,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -48,7 +48,7 @@
 #endif
 
 #define APP_NAME "conference"
-	
+
 EXPORT_SESSION_FACTORY(ConferenceFactory,APP_NAME);
 
 
@@ -87,7 +87,7 @@ int get_audio_file(const string& message, const string& domain, const string& la
       audio_file = string("/tmp/") + APP_NAME + "_" + message + ".wav";
       query_string = "select audio from " + string(DEFAULT_AUDIO_TABLE) + " where application='" + APP_NAME + "' and message='" + message + "' and language=''";
     } else {
-      audio_file = "/tmp/" + domain + "_" + APP_NAME + "_" + 
+      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=''";
     }
@@ -106,7 +106,7 @@ int get_audio_file(const string& message, const string& domain, const string& la
   try {
 
     mysqlpp::Query query = ConferenceFactory::Connection.query();
-	    
+
     DBG("Query string <%s>\n", query_string.c_str());
 
     query << query_string;
@@ -242,7 +242,7 @@ int ConferenceFactory::onLoad()
     return -1;
   }
 
-#else 
+#else
 
   /* Get default audio from file system */
 
@@ -277,14 +277,14 @@ int ConferenceFactory::onLoad()
   }
 
 #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;
@@ -299,7 +299,7 @@ int ConferenceFactory::onLoad()
   MaxParticipants = 0;
   string max_participants = cfg.getParameter("max_participants");
   if (max_participants.length() && str2i(max_participants, MaxParticipants)) {
-    ERROR("while parsing max_participants parameter\n"); 
+    ERROR("while parsing max_participants parameter\n");
   }
 
   UseRFC4240Rooms = cfg.getParameter("use_rfc4240_rooms")=="yes";
@@ -333,7 +333,7 @@ AmSession* ConferenceFactory::onInvite(const AmSipRequest& req, const string& ap
     // see RFC4240 5.  Conference Service
     if (req.user.length()<5)
       throw AmSession::Exception(404, "Not Found");
-    
+
     if (req.user.substr(0,5)!="conf=")
       throw AmSession::Exception(404, "Not Found");
 
@@ -371,7 +371,7 @@ AmSession* ConferenceFactory::onRefer(const AmSipRequest& req, const string& app
 
   AmSession* s = new ConferenceDialog(req.user);
   s->dlg->setLocalTag(req.from_tag);
-  
+
   setupSessionTimer(s);
 
   DBG("ConferenceFactory::onRefer: local_tag = %s\n",s->dlg->getLocalTag().c_str());
@@ -381,8 +381,8 @@ AmSession* ConferenceFactory::onRefer(const AmSipRequest& req, const string& app
 
 ConferenceDialog::ConferenceDialog(const string& conf_id,
 				   AmConferenceChannel* dialout_channel)
-  : conf_id(conf_id), 
-    channel(0),
+  : conf_id(conf_id),
+    channel(nullptr),
     play_list(this),
     dialout_channel(dialout_channel),
     state(CS_normal),
@@ -392,7 +392,7 @@ ConferenceDialog::ConferenceDialog(const string& conf_id,
   RTPStream()->setPlayoutType(ConferenceFactory::m_PlayoutType);
 #ifdef WITH_SAS_TTS
   tts_voice = register_cmu_us_kal();
-#endif  
+#endif
 }
 
 ConferenceDialog::~ConferenceDialog()
@@ -417,7 +417,7 @@ void ConferenceDialog::onStart() {
 void ConferenceDialog::onInvite(const AmSipRequest& req)
 {
   if(dlg->getStatus() == AmSipDialog::Connected){
-    AmSession::onInvite(req);  
+    AmSession::onInvite(req);
     return;
   }
 
@@ -429,14 +429,14 @@ void ConferenceDialog::onInvite(const AmSipRequest& req)
   if (app_param_hdr.length()) {
     from_header = get_header_keyvalue(app_param_hdr, "Dialout-From");
     extra_headers = get_header_keyvalue(app_param_hdr, "Dialout-Extra");
-    dialout_suffix = get_header_keyvalue(app_param_hdr, "Dialout-Suffix");      
+    dialout_suffix = get_header_keyvalue(app_param_hdr, "Dialout-Suffix");
     language = get_header_keyvalue(app_param_hdr, "Language");
     listen_only_str = get_header_keyvalue(app_param_hdr, "Listen-Only");
   } else {
     from_header = getHeader(req.hdrs, "P-Dialout-From", true);
     extra_headers = getHeader(req.hdrs, "P-Dialout-Extra", true);
     dialout_suffix = getHeader(req.hdrs, "P-Dialout-Suffix", true);
-    if (from_header.length() || extra_headers.length() 
+    if (from_header.length() || extra_headers.length()
 	|| dialout_suffix.length()) {
       DBG("Warning: P-Dialout- style headers are deprecated."
 	  " Please use P-App-Param header instead.\n");
@@ -463,7 +463,7 @@ void ConferenceDialog::onInvite(const AmSipRequest& req)
       dialout_suffix = "";
     }
   }
-    
+
   allow_dialout = dialout_suffix.length() > 0;
 
   listen_only = listen_only_str.length() > 0;
@@ -502,7 +502,7 @@ void ConferenceDialog::onInvite(const AmSipRequest& req)
   DBG("Using LonelyUserFile <%s>\n",
       ConferenceFactory::LonelyUserFile.c_str());
 
-  AmSession::onInvite(req);  
+  AmSession::onInvite(req);
 }
 
 void ConferenceDialog::onSessionStart()
@@ -523,7 +523,7 @@ void ConferenceDialog::onSessionStart()
 void ConferenceDialog::setupAudio()
 {
   if(!ConferenceFactory::JoinSound.empty()) {
-	
+
     JoinSound.reset(new AmAudioFile());
     if(JoinSound->open(ConferenceFactory::JoinSound,
 		       AmAudioFile::Read))
@@ -531,7 +531,7 @@ void ConferenceDialog::setupAudio()
   }
 
   if(!ConferenceFactory::DropSound.empty()) {
-	
+
     DropSound.reset(new AmAudioFile());
     if(DropSound->open(ConferenceFactory::DropSound,
 		       AmAudioFile::Read))
@@ -565,11 +565,11 @@ void ConferenceDialog::setupAudio()
   }
 
   setInOut(&play_list,&play_list);
-    
+
   setCallgroup(conf_id);
-  
+
   MONITORING_LOG(getLocalTag().c_str(), "conf_id", conf_id.c_str());
-	
+
   if(dialedout || !allow_dialout) {
     DBG("Dialout not enabled or dialout channel. Disabling DTMF detection.\n");
     setDtmfDetectionEnabled(false);
@@ -593,30 +593,30 @@ void ConferenceDialog::process(AmEvent* ev)
     case ConfNewParticipant:
 
       DBG("########## new participant #########\n");
-      if((ce->participants == 1) && 
+      if((ce->participants == 1) &&
 	 !ConferenceFactory::LonelyUserFile.empty() ){
 
 	if(!LonelyUserFile.get()){
-			
+
 	  LonelyUserFile.reset(new AmAudioFile());
 	  if(LonelyUserFile->open(ConferenceFactory::LonelyUserFile,
 				  AmAudioFile::Read))
 	    LonelyUserFile.reset(0);
 	}
-		
+
 	if(LonelyUserFile.get())
 	  play_list.addToPlayListFront(
 				       new AmPlaylistItem( LonelyUserFile.get(), NULL ));
       }
       else {
-		
+
 	if(JoinSound.get()){
 	  JoinSound->rewind();
 	  play_list.addToPlayListFront(
 				       new AmPlaylistItem( JoinSound.get(), NULL ));
 	}
       }
-		
+
       break;
     case ConfParticipantLeft:
       DBG("########## participant left the room #########\n");
@@ -643,9 +643,9 @@ void ConferenceDialog::process(AmEvent* ev)
 
 	connectMainChannel();
 	break;
-	
+
       case DoConfDisconnect:
-		
+
 	dlg->bye();
 	closeChannels();
 	setStopped();
@@ -656,7 +656,7 @@ void ConferenceDialog::process(AmEvent* ev)
       }
     }
     else {
-	    
+
       switch(do_ev->event_id){
 
       case DoConfDisconnect:
@@ -676,7 +676,7 @@ void ConferenceDialog::process(AmEvent* ev)
 	break;
 
       case DoConfRinging:
-		
+
 	if(!RingTone.get())
 	  RingTone.reset(new AmRingTone(0,2000,4000,440,480)); // US
 
@@ -686,7 +686,7 @@ void ConferenceDialog::process(AmEvent* ev)
 	break;
 
       case DoConfError:
-		
+
 	DBG("****** Caller received DoConfError *******\n");
 	if(!ErrorTone.get())
 	  ErrorTone.reset(new AmRingTone(2000,250,250,440,480));
@@ -694,7 +694,7 @@ void ConferenceDialog::process(AmEvent* ev)
 	DBG("adding error tone to the playlist (dialedout = %i)\n",dialedout);
 	play_list.addToPlayListFront(new AmPlaylistItem(ErrorTone.get(),NULL));
 	break;
-		
+
       }
     }
 
@@ -712,7 +712,7 @@ string dtmf2str(int event)
   case 6: case 7: case 8:
   case 9:
     return int2str(event);
-	
+
   case 10: return "*";
   case 11: return "#";
   default: return "";
@@ -725,12 +725,12 @@ void ConferenceDialog::onDtmf(int event, int duration)
   DBG("ConferenceDialog::onDtmf\n");
   if (dialedout || !allow_dialout ||
       ((ConferenceFactory::MaxParticipants > 0) &&
-       (AmConferenceStatus::getConferenceSize(dlg->getUser()) >= 
+       (AmConferenceStatus::getConferenceSize(dlg->getUser()) >=
 	ConferenceFactory::MaxParticipants)))
     return;
 
   switch(state){
-	
+
   case CS_normal:
     DBG("CS_normal\n");
     dtmf_seq += dtmf2str(event);
@@ -749,7 +749,7 @@ void ConferenceDialog::onDtmf(int event, int duration)
 	dtmf_seq = "";
       } else {
 	// keep last digit
-	dtmf_seq = dtmf_seq[1]; 
+	dtmf_seq = dtmf_seq[1];
       }
     }
     break;
@@ -759,7 +759,7 @@ void ConferenceDialog::onDtmf(int event, int duration)
     string digit = dtmf2str(event);
 
     if(digit == "*"){
-	    
+
       if(!dtmf_seq.empty()){
 	createDialoutParticipant(dtmf_seq);
 	state = CS_dialed_out;
@@ -771,7 +771,7 @@ void ConferenceDialog::onDtmf(int event, int duration)
 
       dtmf_seq = "";
     }
-    else 
+    else
       dtmf_seq += digit;
 
   } break;
@@ -797,7 +797,7 @@ void ConferenceDialog::onDtmf(int event, int duration)
       state = CS_normal;
     }
     break;
-	
+
   }
 }
 
@@ -810,8 +810,8 @@ void ConferenceDialog::createDialoutParticipant(const string& uri_user)
   dialout_channel.reset(AmConferenceStatus::getChannel(getLocalTag(),getLocalTag(),RTPStream()->getSampleRate()));
 
   dialout_id = AmSession::getNewId();
-    
-  ConferenceDialog* dialout_session = 
+
+  ConferenceDialog* dialout_session =
     new ConferenceDialog(conf_id,
 			 AmConferenceStatus::getChannel(getLocalTag(),
 							dialout_id,RTPStream()->getSampleRate()));
@@ -843,9 +843,9 @@ void ConferenceDialog::createDialoutParticipant(const string& uri_user)
 void ConferenceDialog::disconnectDialout()
 {
   if(dialedout){
-	
+
     if(dialout_channel.get()){
-	    
+
       AmSessionContainer::instance()
 	->postEvent(dialout_channel->getConfID(),
 		    new DialoutConfEvent(DoConfDisconnect,
@@ -858,7 +858,7 @@ void ConferenceDialog::disconnectDialout()
       ->postEvent(dialout_id,
 		  new DialoutConfEvent(DoConfDisconnect,
 				       getLocalTag()));
-    
+
     connectMainChannel();
   }
 }
@@ -868,7 +868,7 @@ void ConferenceDialog::connectMainChannel()
   dialout_id = "";
   dialedout = false;
   dialout_channel.reset(NULL);
-    
+
   play_list.flush();
 
   if(!channel.get())
@@ -924,14 +924,14 @@ void ConferenceDialog::onSipRequest(const AmSipRequest& req)
 }
 
 void ConferenceDialog::onSipReply(const AmSipRequest& req,
-				  const AmSipReply& reply, 
+				  const AmSipReply& reply,
 				  AmBasicSipDialog::Status old_dlg_status)
 {
   AmSession::onSipReply(req, reply, old_dlg_status);
 
   DBG("ConferenceDialog::onSipReply: code = %i, reason = %s\n, status = %i\n",
       reply.code,reply.reason.c_str(),dlg->getStatus());
-    
+
   if(!dialedout /*&& !transfer_req.get()*/)
     return;
 
@@ -954,7 +954,7 @@ void ConferenceDialog::onSipReply(const AmSipRequest& req,
 			new DialoutConfEvent(DoConfRinging,
 					     dialout_channel->getConfID()));
 	}
-		
+
 	break;
       default:  break;// continue waiting.
       }
@@ -963,7 +963,7 @@ void ConferenceDialog::onSipReply(const AmSipRequest& req,
     case AmSipDialog::Disconnected:
 
       // if(!transfer_req.get()){
-      
+
       if(dialout_channel.get()){
 	disconnectDialout();
 	AmSessionContainer::instance()
@@ -994,28 +994,28 @@ void ConferenceDialog::onZRTPEvent(zrtp_event_t event, zrtp_stream_ctx_t *stream
   case ZRTP_EVENT_IS_SECURE: {
     INFO("ZRTP_EVENT_IS_SECURE \n");
     //         info->is_verified  = ctx->_session_ctx->secrets.verifieds & ZRTP_BIT_RS0;
-    
+
     zrtp_conn_ctx_t *session = stream_ctx->_session_ctx;
-    
+
     string tts_sas = "My SAS is ";
-    
+
     if (ZRTP_SAS_BASE32 == session->sas_values.rendering) {
       DBG("Got SAS value <<<%.4s>>>\n", session->sas_values.str1.buffer);
       tts_sas += session->sas_values.str1.buffer;
     } else {
-      DBG("Got SAS values SAS1 '%s' and SAS2 '%s'\n", 
+      DBG("Got SAS values SAS1 '%s' and SAS2 '%s'\n",
 	  session->sas_values.str1.buffer,
 	  session->sas_values.str2.buffer);
-      tts_sas += session->sas_values.str1.buffer + string(" and ") + 
+      tts_sas += session->sas_values.str1.buffer + string(" and ") +
 	session->sas_values.str2.buffer + ".";
     }
-    
+
     sayTTS(tts_sas);
     return;
   } break;
   default: break;
-  } 
-  AmSession::onZRTPEvent(event, stream_ctx);  
+  }
+  AmSession::onZRTPEvent(event, stream_ctx);
 }
 
 void ConferenceDialog::sayTTS(string text) {
@@ -1025,7 +1025,7 @@ void ConferenceDialog::sayTTS(string text) {
 
   last_sas = text;
   flite_text_to_speech(text.c_str(),tts_voice,filename.c_str());
-  
+
   AmAudioFile* af = new AmAudioFile();
   if(!af->open(filename.c_str(), AmAudioFile::Read)) {
     play_list.addToPlayListFront(new AmPlaylistItem(af, NULL));
diff --git a/apps/dsm/mods/CMakeLists.txt b/apps/dsm/mods/CMakeLists.txt
index 6d4d3da9..dd90c7d5 100644
--- a/apps/dsm/mods/CMakeLists.txt
+++ b/apps/dsm/mods/CMakeLists.txt
@@ -9,7 +9,9 @@ ENDIF(SEMS_USE_MONITORING)
 IF(MYSQLPP_FOUND)
 	ADD_SUBDIRECTORY (mod_mysql)
 ENDIF(MYSQLPP_FOUND)
-ADD_SUBDIRECTORY (mod_py)
+IF(PYTHONLIBS_FOUND)
+	ADD_SUBDIRECTORY (mod_py)
+ENDIF(PYTHONLIBS_FOUND)
 #ADD_SUBDIRECTORY (mod_redis)
 ADD_SUBDIRECTORY (mod_regex)
 #ADD_SUBDIRECTORY (mod_sbc)
@@ -19,4 +21,3 @@ ADD_SUBDIRECTORY (mod_uri)
 ADD_SUBDIRECTORY (mod_utils)
 #ADD_SUBDIRECTORY (mod_xml)
 #ADD_SUBDIRECTORY (mod_zrtp)
-
diff --git a/apps/sbc/SBCEventLog.cpp b/apps/sbc/SBCEventLog.cpp
index 9ec3118c..76cbcb25 100644
--- a/apps/sbc/SBCEventLog.cpp
+++ b/apps/sbc/SBCEventLog.cpp
@@ -33,9 +33,10 @@
 struct MonitoringEventLogHandler
   : public SBCEventLogHandler
 {
-  void logEvent(long int timestamp, const string& id, 
+  void logEvent(long int timestamp, const string& id,
 		const string& type, const AmArg& event) {
 
+#ifdef USE_MONITORING
     if(NULL != MONITORING_GLOBAL_INTERFACE) {
       AmArg di_args,ret;
       di_args.push(id);
@@ -49,11 +50,13 @@ struct MonitoringEventLogHandler
       MONITORING_GLOBAL_INTERFACE->
 	invoke("log", di_args, ret);
     }
+#endif
   }
 };
 
 void _SBCEventLog::useMonitoringLog()
 {
+#ifdef USE_MONITORING
   if(NULL != MONITORING_GLOBAL_INTERFACE) {
     setEventLogHandler(new MonitoringEventLogHandler());
     INFO("SBC event log will use the monitoring module\n");
@@ -62,6 +65,7 @@ void _SBCEventLog::useMonitoringLog()
     ERROR("SBC event log cannot use the monitoring module"
 	  " as it is not loaded\n");
   }
+#endif
 }
 
 void _SBCEventLog::setEventLogHandler(SBCEventLogHandler* lh)
@@ -95,7 +99,7 @@ void _SBCEventLog::logCallStart(const AmSipRequest& req,
 
   if(uri_parser.parse_contact(req.from,0,end))
     start_event["from"] = uri_parser.uri_str();
-  else 
+  else
     start_event["from"] = req.from;
 
   start_event["from-ua"] = from_remote_ua;
@@ -103,7 +107,7 @@ void _SBCEventLog::logCallStart(const AmSipRequest& req,
 
   if(uri_parser.parse_contact(req.to,0,end))
     start_event["to"] = uri_parser.uri_str();
-  else 
+  else
     start_event["to"] = req.to;
 
   start_event["to-ua"] = to_remote_ua;
@@ -118,7 +122,7 @@ void _SBCEventLog::logCallStart(const AmSipRequest& req,
 	   start_event);
 }
 
-  
+
 
 void _SBCEventLog::logCallEnd(const AmSipRequest& req,
 			      const string& local_tag,
@@ -132,7 +136,7 @@ void _SBCEventLog::logCallEnd(const AmSipRequest& req,
   end_event["source"]   = req.remote_ip;
   end_event["src-port"] = req.remote_port;
   end_event["r-uri"]    = req.r_uri;
-  
+
   size_t end;
   AmUriParser uri_parser;
   if(uri_parser.parse_contact(req.from,0,end))
@@ -166,7 +170,7 @@ void _SBCEventLog::logCallEnd(const AmBasicSipDialog* dlg,
   end_event["call-id"] = dlg->getCallid();
   end_event["reason"]  = reason;
   end_event["r-uri"]   = dlg->getLocalUri();
-  
+
   size_t end;
   AmUriParser uri_parser;
 
diff --git a/apps/voicemail/AnswerMachine.cpp b/apps/voicemail/AnswerMachine.cpp
index 19928949..0e375b3a 100644
--- a/apps/voicemail/AnswerMachine.cpp
+++ b/apps/voicemail/AnswerMachine.cpp
@@ -18,8 +18,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -99,7 +99,7 @@ const char* MsgStrError(int e) {
   case MSG_EALREADYCLOSED: return "MSG_EALREADYCLOSED"; break;
   case MSG_EREADERROR: return "MSG_EREADERROR"; break;
   case MSG_ENOSPC: return "MSG_ENOSPC"; break;
-  case MSG_ESTORAGE: return "MSG_ESTORAGE"; break;   
+  case MSG_ESTORAGE: return "MSG_ESTORAGE"; break;
   default: return "Unknown Error";
   }
 }
@@ -119,36 +119,36 @@ int get_audio_file(const string& message, const string& domain, const string& us
   if (!user.empty()) {
     audio_file = string("/tmp/") + domain + "_" + user + "_" +
       MOD_NAME + "_" + message + ".wav";
-    query_string = "select audio from " + string(USER_AUDIO_TABLE) + 
-      " where application='" + MOD_NAME + "' and message='" + message + 
+    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 + 
+       query_string = "select audio from " + string(DEFAULT_AUDIO_TABLE) +
+	 " where application='" + MOD_NAME + "' and message='" + message +
 	 "' and language=''";
       } 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 + 
+       query_string = "select audio from " + string(DOMAIN_AUDIO_TABLE) +
+	 " where application='" + MOD_NAME + "' and message='" + message +
 	 "' and domain='" + domain + "' and language=''";
       }
     } 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 + 
+       query_string = "select audio from " + string(DEFAULT_AUDIO_TABLE) +
+	 " where application='" + MOD_NAME + "' and message='" + message +
 	 "' and language='" + language + "'";
       } else {
        audio_file = string("/tmp/") + domain + "_" + MOD_NAME + "_" +
          message + "_" + language + ".wav";
-       query_string = "select audio from " + string(DOMAIN_AUDIO_TABLE) + 
-	 " where application='" + MOD_NAME + "' and message='" + message + 
+       query_string = "select audio from " + string(DOMAIN_AUDIO_TABLE) +
+	 " where application='" + MOD_NAME + "' and message='" + message +
 	 "' and domain='" + domain + "' and language='" + language + "'";
       }
     }
@@ -200,9 +200,9 @@ int AnswerMachineFactory::loadEmailTemplatesFromMySQL()
     mysqlpp::Query query = AnswerMachineFactory::Connection.query();
 
     string query_string, table;
-    query_string = "select replace(template, '\r', '') as template, " 
-      "language from " + string(DEFAULT_TEMPLATE_TABLE) + 
-      " where application='" + MOD_NAME + 
+    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());
@@ -248,7 +248,7 @@ int AnswerMachineFactory::loadEmailTemplatesFromMySQL()
     }
 
     query_string = "select domain, replace(template, '\r', '') as template, "
-      "language from " + string(DOMAIN_TEMPLATE_TABLE) + 
+      "language from " + string(DOMAIN_TEMPLATE_TABLE) +
       " where application='" + MOD_NAME +"' and message='" + EMAIL_TMPL + "'";
 
     DBG("Query string <%s>\n", query_string.c_str());
@@ -304,10 +304,10 @@ int AnswerMachineFactory::loadEmailTemplatesFromMySQL()
 
 int AnswerMachineFactory::loadEmailTemplates(const string& path)
 {
-  string email_tmpl_file = add2path(path, 1, 
+  string email_tmpl_file = add2path(path, 1,
 				    (DEFAULT_MAIL_TMPL + "."
 				     + DEFAULT_MAIL_TMPL_EXT).c_str());
-    
+
   EmailTemplate& tmpl = email_tmpl[DEFAULT_MAIL_TMPL];
   if(tmpl.load(email_tmpl_file)){
     ERROR("Voicemail: could not load default"
@@ -332,7 +332,7 @@ int AnswerMachineFactory::loadEmailTemplates(const string& path)
     string tmpl_file = add2path(path,1,entry->d_name);
     string tmpl_name = entry->d_name;
 
-    if( (tmpl_name.length() <= file_ext.length()) 
+    if( (tmpl_name.length() <= file_ext.length())
 	|| tmpl_name.substr( tmpl_name.length()
 			     - file_ext.length(),
 			     file_ext.length() )
@@ -370,7 +370,7 @@ int AnswerMachineFactory::onLoad()
 
   // smtp_server
   SmtpServerAddress = cfg.getParameter("smtp_server",SmtpServerAddress);
-  
+
   // smtp_port
   if(cfg.hasParameter("smtp_port")){
     if(sscanf(cfg.getParameter("smtp_port").c_str(),
@@ -379,7 +379,7 @@ int AnswerMachineFactory::onLoad()
       return -1;
     }
   }
-  
+
   DBG("SMTP server set to %s:%u\n",
       SmtpServerAddress.c_str(), SmtpServerPort);
 
@@ -436,7 +436,7 @@ int AnswerMachineFactory::onLoad()
 #else
 
   /* Get email templates from file system */
-  
+
   if(loadEmailTemplates(cfg.getParameter("email_template_path",
 					 DEFAULT_MAIL_TMPL_PATH))){
     ERROR("while loading email templates\n");
@@ -462,10 +462,10 @@ int AnswerMachineFactory::onLoad()
     }
   }
 
-  TryPersonalGreeting = 
+  TryPersonalGreeting =
     cfg.getParameter("try_personal_greeting") == "yes";
 
-  DBG("voicemail will %stry to find a personal greeting.\n", 
+  DBG("voicemail will %stry to find a personal greeting.\n",
       TryPersonalGreeting?"":"not ");
 
   MailHeaderVariables = explode(cfg.getParameter("mail_header_vars"), ";");
@@ -475,16 +475,16 @@ int AnswerMachineFactory::onLoad()
 	   MailHeaderVariables.begin(); it != MailHeaderVariables.end(); it++) {
       DBG("         %s\n", it->c_str());
     }
-  }    
+  }
 
   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", 
+  DBG("Voicebox will%s save empty messages.\n",
       SaveEmptyMsg?"":" not");
 
   // override email address
@@ -509,7 +509,7 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req, const string&
 
   EmailTmplDict template_variables;
 
-  int vm_mode = DefaultVMMode; 
+  int vm_mode = DefaultVMMode;
 
   if(SimpleMode) {
     email = EmailAddress;
@@ -520,19 +520,19 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req, const string&
     typ = DEFAULT_TYPE;
   }
   else {
-  
+
     iptel_app_param = getHeader(req.hdrs, PARAM_HDR, true);
     mode = get_header_keyvalue(iptel_app_param,"mod", "Mode");
-    
+
     if (!EmailAddress.length()) {
-      
+
       if (!iptel_app_param.length()) {
 	throw AmSession::Exception(500, "voicemail: parameters not found");
       }
-      
+
       language = get_header_keyvalue(iptel_app_param, "lng", "Language");
       email = get_header_keyvalue(iptel_app_param, "eml", "Email-Address");
-      
+
       if (!mode.empty()) {
 	if (mode == "box")
 	  vm_mode = MODE_BOX;
@@ -546,52 +546,52 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req, const string&
       //vm_mode = MODE_VOICEMAIL;
       email = EmailAddress;
     }
-    
+
     if (((vm_mode == MODE_BOTH) || (vm_mode == MODE_VOICEMAIL)) &&
 	(email.find('@') == string::npos)) {
       ERROR("no @ found in email address '%s' from params '%s'\n",
 	    email.c_str(), iptel_app_param.c_str());
       throw AmSession::Exception(500, "voicemail: no email address");
     }
-    
+
     user = get_header_keyvalue(iptel_app_param,"usr", "User");
     if (!user.length())
       user = req.user;
-    
+
     sender = get_header_keyvalue(iptel_app_param, "snd", "Sender");
-    if (!sender.length()) 
-      sender = req.from;  
-    
+    if (!sender.length())
+      sender = req.from;
+
     domain = get_header_keyvalue(iptel_app_param, "dom", "Domain");
     if (!domain.length())
       domain = req.domain;
-    
+
     typ = get_header_keyvalue(iptel_app_param, "typ", "Type");
     if (!typ.length())
       typ = DEFAULT_TYPE;
-    
+
     uid = get_header_keyvalue(iptel_app_param, "uid", "UserID");
     if (uid.empty())
       uid=user;
-    
+
     did = get_header_keyvalue(iptel_app_param, "did", "DomainID");
     if (did.empty())
       did=domain;
   }
-    
+
   // checks
-  if (uid.empty()) 
+  if (uid.empty())
     throw AmSession::Exception(500, "voicemail: user missing");
-  
-  if (sender.empty()) 
+
+  if (sender.empty())
     throw AmSession::Exception(500, "voicemail: sender missing");
-  
+
   if (((vm_mode == MODE_BOX) || (vm_mode == MODE_BOTH))
       && (NULL == MessageStorage)) {
     throw AmSession::Exception(500, "voicemail: no message storage available");
   }
-  
-  
+
+
   DBG("voicemail invocation parameters: \n");
   DBG(" Mode:     <%s> \n", mode.c_str());
   DBG(" Email:    <%s> \n", email.c_str());
@@ -602,7 +602,7 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req, const string&
   DBG(" Type:     <%s> \n", typ.c_str());
   DBG(" UID:      <%s> \n", uid.c_str());
   DBG(" DID:      <%s> \n", did.c_str());
-  
+
   FILE* greeting_fp = NULL;
   if (TryPersonalGreeting)
     greeting_fp = getMsgStoreGreeting(typ, uid, did);
@@ -634,28 +634,28 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req, const string&
 
 #else
 
-  string announce_file = add2path(AnnouncePath,2, 
+  string announce_file = add2path(AnnouncePath,2,
 				  did.c_str(), (uid + ".wav").c_str());
   if (file_exists(announce_file)) goto announce_found;
 
   if (!language.empty()) {
-    announce_file = add2path(AnnouncePath,3, 
+    announce_file = add2path(AnnouncePath,3,
 			     did.c_str(), language.c_str(), DefaultAnnounce.c_str());
     if (file_exists(announce_file)) goto announce_found;
   }
 
-  announce_file = add2path(AnnouncePath,2, 
+  announce_file = add2path(AnnouncePath,2,
 			   did.c_str(), DefaultAnnounce.c_str());
   if (file_exists(announce_file)) goto announce_found;
 
   if (!language.empty()) {
-    announce_file = add2path(AnnouncePath,2, 
+    announce_file = add2path(AnnouncePath,2,
 			     language.c_str(),  DefaultAnnounce.c_str());
     if (file_exists(announce_file)) goto announce_found;
   }
-	
+
   announce_file = add2path(AnnouncePath,1, DefaultAnnounce.c_str());
-  if (!file_exists(announce_file)) 
+  if (!file_exists(announce_file))
     announce_file = "";
 
 #endif
@@ -676,8 +676,8 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req, const string&
   // VBOX mode does not need email template
   if ((vm_mode == MODE_BOX) || (vm_mode == MODE_ANN))
     return new AnswerMachineDialog(user, sender, domain,
-				   email, announce_file, uid, did, 
-				   greeting_fp, vm_mode, 
+				   email, announce_file, uid, did,
+				   greeting_fp, vm_mode,
 				   template_variables, NULL);
 
   if(email.empty())
@@ -700,13 +700,13 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req, const string&
     if(tmpl_it == email_tmpl.end())
       tmpl_it = email_tmpl.find(DEFAULT_MAIL_TMPL);
   }
-    
+
   if(tmpl_it == email_tmpl.end()){
     ERROR("Voicemail: unable to find an email template.\n");
     return 0;
   }
   return new AnswerMachineDialog(user, sender, domain,
-				 email, announce_file, 
+				 email, announce_file,
 				 uid, did,
 				 greeting_fp,
 				 vm_mode, template_variables,
@@ -714,19 +714,19 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req, const string&
 }
 
 
-AnswerMachineDialog::AnswerMachineDialog(const string& user, 
-					 const string& sender, 
+AnswerMachineDialog::AnswerMachineDialog(const string& user,
+					 const string& sender,
 					 const string& domain,
-					 const string& email, 
-					 const string& announce_file, 
+					 const string& email,
+					 const string& announce_file,
 					 const string& uid,
 					 const string& did,
-					 FILE* announce_fp, 
+					 FILE* announce_fp,
 					 int vm_mode,
 					 const EmailTmplDict& template_variables,
-					 const EmailTemplate* tmpl) 
+					 const EmailTemplate* tmpl)
   : announce_file(announce_file), announce_fp(announce_fp),
-    tmpl(tmpl), playlist(this), 
+    tmpl(tmpl), playlist(this),
   status(0), vm_mode(vm_mode),
   email_dict(template_variables)
 
@@ -792,7 +792,7 @@ void AnswerMachineDialog::process(AmEvent* event)
 void AnswerMachineDialog::onNoAudio()
 {
   switch(status){
-    
+
   case 0: {
     // announcement mode - no recording
     if (MODE_ANN == vm_mode) {
@@ -800,11 +800,11 @@ void AnswerMachineDialog::onNoAudio()
       setStopped();
       return;
     }
-    
+
     playlist.addToPlaylist(new AmPlaylistItem(NULL,&a_msg));
-    
+
     setTimer(RECORD_TIMER, AnswerMachineFactory::MaxRecordTime);
-    
+
     status = 1;
   } break;
 
@@ -813,13 +813,13 @@ void AnswerMachineDialog::onNoAudio()
     playlist.addToPlaylist(new AmPlaylistItem(&a_beep,NULL));
     status = 2;
     break;
-    
+
   case 2:
     dlg->bye();
     saveMessage();
     setStopped();
     break;
-    
+
   }
 }
 
@@ -840,7 +840,7 @@ void AnswerMachineDialog::onSessionStart()
 
   if (announce_fp) {
     rewind(announce_fp);
-    if (a_greeting.fpopen(DEFAULT_TYPE"."DEFAULT_AUDIO_EXT, 
+    if (a_greeting.fpopen(DEFAULT_TYPE "." DEFAULT_AUDIO_EXT,
 			  AmAudioFile::Read, announce_fp) ||
 	a_beep.open(beep_file,AmAudioFile::Read)) {
       if (a_greeting.open(announce_file.c_str(),AmAudioFile::Read) ||
@@ -854,7 +854,7 @@ void AnswerMachineDialog::onSessionStart()
   }
 #else
   if (announce_fp) {
-    if (a_greeting.fpopen(DEFAULT_TYPE"."DEFAULT_AUDIO_EXT, 
+    if (a_greeting.fpopen(DEFAULT_TYPE "." DEFAULT_AUDIO_EXT,
 			  AmAudioFile::Read, announce_fp) ||
 	a_beep.open(add2path(AnswerMachineFactory::AnnouncePath,1, "beep.wav"),
 		    AmAudioFile::Read))
@@ -869,17 +869,17 @@ void AnswerMachineDialog::onSessionStart()
 
   msg_filename = "/tmp/" + getLocalTag() + "."
     + AnswerMachineFactory::RecFileExt;
-    
+
   if (vm_mode != MODE_ANN) {
     if(a_msg.open(msg_filename,AmAudioFile::Write,true))
-      throw string("AnswerMachine: couldn't open ") + 
+      throw string("AnswerMachine: couldn't open ") +
 	msg_filename + string(" for writing");
   }
 
   //a_msg.setRecordTime(AnswerMachineFactory::MaxRecordTime*1000);
-    
+
   playlist.addToPlaylist(new AmPlaylistItem(&a_greeting,NULL));
-  if (vm_mode != MODE_ANN) 
+  if (vm_mode != MODE_ANN)
     playlist.addToPlaylist(new AmPlaylistItem(&a_beep,NULL));
   //playlist.addToPlaylist(new AmPlaylistItem(NULL,&a_msg));
 
@@ -909,7 +909,7 @@ void AnswerMachineDialog::saveMessage()
 
   int rec_length = a_msg.getLength();
   char rec_len_str[10];
-  snprintf(rec_len_str, sizeof(rec_len_str), 
+  snprintf(rec_len_str, sizeof(rec_len_str),
 	   "%.2f", float(rec_length)/1000.0);
   string rec_len_s = rec_len_str;
 
@@ -921,7 +921,7 @@ void AnswerMachineDialog::saveMessage()
   if(!rec_size){
     // record in box empty messages as well
     if (AnswerMachineFactory::SaveEmptyMsg &&
-	((vm_mode == MODE_BOX) || 
+	((vm_mode == MODE_BOX) ||
 	 (vm_mode == MODE_BOTH))) {
       saveBox(NULL);
     }
@@ -933,7 +933,7 @@ void AnswerMachineDialog::saveMessage()
       a_msg.on_close();
 
       // copy to tmpfile for box msg
-      if ((vm_mode == MODE_BOTH) ||  
+      if ((vm_mode == MODE_BOTH) ||
 	  (vm_mode == MODE_BOX))  {
 	DBG("will save to box...\n");
 	FILE* m_fp = a_msg.getfp();
@@ -958,9 +958,9 @@ void AnswerMachineDialog::saveMessage()
 	}
 	saveBox(m_fp);
       }
-	    
+
       if ((vm_mode == MODE_BOTH) ||
-	  (vm_mode == MODE_VOICEMAIL)) { 
+	  (vm_mode == MODE_VOICEMAIL)) {
 	// send mail
 	AmMail* mail = new AmMail(tmpl->getEmail(email_dict));
 	mail->attachements.push_back(Attachement(a_msg.getfp(),
@@ -977,7 +977,7 @@ void AnswerMachineDialog::saveMessage()
 }
 
 void AnswerMachineDialog::saveBox(FILE* fp) {
-  string msg_name = email_dict["ts"] + MSG_SEPARATOR +  
+  string msg_name = email_dict["ts"] + MSG_SEPARATOR +
     email_dict["sender"] + "." + AnswerMachineFactory::RecFileExt;
   DBG("message name is '%s'\n", msg_name.c_str());
 
@@ -988,16 +988,16 @@ void AnswerMachineDialog::saveBox(FILE* fp) {
   AmArg df;
   MessageDataFile df_arg(fp);
   df.setBorrowedPointer(&df_arg);
-  di_args.push(df);  
-  msg_storage->invoke("msg_new",di_args,ret);  
+  di_args.push(df);
+  msg_storage->invoke("msg_new",di_args,ret);
   // TODO: evaluate ret return value
   if (fp)
     fclose(fp);
 }
 
 
-FILE* AnswerMachineFactory::getMsgStoreGreeting(string msgname, 
-						string user, 
+FILE* AnswerMachineFactory::getMsgStoreGreeting(string msgname,
+						string user,
 						string domain) {
   if (!msg_storage)
     return NULL;
@@ -1012,8 +1012,8 @@ FILE* AnswerMachineFactory::getMsgStoreGreeting(string msgname,
   di_args.push(user.c_str());    // user
   di_args.push(msgname.c_str()); // msg name
 
-  msg_storage->invoke("msg_get",di_args,ret);  
-  if (!ret.size()  
+  msg_storage->invoke("msg_get",di_args,ret);
+  if (!ret.size()
       || !isArgInt(ret.get(0))) {
     ERROR("msg_get for user '%s' domain '%s' msg '%s'"
 	  " returned no (valid) result.\n",
@@ -1030,15 +1030,15 @@ FILE* AnswerMachineFactory::getMsgStoreGreeting(string msgname,
 	  MsgStrError(ret.get(0).asInt()));
 
     if ((ret.size() > 1) && isArgAObject(ret.get(1))) {
-      MessageDataFile* f = 
+      MessageDataFile* f =
 	dynamic_cast<MessageDataFile*>(ret.get(1).asObject());
       if (NULL != f)
 	delete f;
     }
 
     return NULL;
-  } 
-  
+  }
+
   if ((ret.size() < 2) ||
       (!isArgAObject(ret.get(1)))) {
     ERROR("msg_get for user '%s' domain '%s' message '%s': "
@@ -1047,7 +1047,7 @@ FILE* AnswerMachineFactory::getMsgStoreGreeting(string msgname,
 	  msgname.c_str());
     return NULL;
   }
-  MessageDataFile* f = 
+  MessageDataFile* f =
     dynamic_cast<MessageDataFile*>(ret.get(1).asObject());
   if (NULL == f)
     return NULL;