Browse code

changed sip dialog attribute in AmSession into a pointer.

Raphael Coeffic authored on 07/01/2013 16:27:13
Showing 1 changed files
... ...
@@ -271,7 +271,7 @@ void EarlyAnnounceDialog::onInvite(const AmSipRequest& req)
271 271
   AmMimeBody sdp_body;
272 272
   sdp_body.addPart(SIP_APPLICATION_SDP);
273 273
 
274
-  if(dlg.reply(req,183,"Session Progress",
274
+  if(dlg->reply(req,183,"Session Progress",
275 275
 	       &sdp_body) != 0){
276 276
     throw AmSession::Exception(500,"could not reply");
277 277
   } else {
... ...
@@ -358,7 +358,7 @@ void EarlyAnnounceDialog::onBye(const AmSipRequest& req)
358 358
 
359 359
 void EarlyAnnounceDialog::onCancel(const AmSipRequest& req)
360 360
 {
361
-  dlg.reply(invite_req,487,"Call terminated");
361
+  dlg->reply(invite_req,487,"Call terminated");
362 362
   setStopped();
363 363
 }
364 364
 
... ...
@@ -413,7 +413,7 @@ void EarlyAnnounceDialog::process(AmEvent* event)
413 413
 	}
414 414
 
415 415
 	DBG("Replying with code %d %s\n", code_i, reason.c_str());
416
-	dlg.reply(invite_req, code_i, reason);
416
+	dlg->reply(invite_req, code_i, reason);
417 417
 	
418 418
 	setStopped();
419 419
       } else {
Browse code

multi-mime: plugins: adapt to core API changes.

Raphael Coeffic authored on 20/02/2012 09:10:35
Showing 1 changed files
... ...
@@ -268,8 +268,11 @@ int EarlyAnnounceFactory::onLoad()
268 268
 
269 269
 void EarlyAnnounceDialog::onInvite(const AmSipRequest& req) 
270 270
 {
271
+  AmMimeBody sdp_body;
272
+  sdp_body.addPart(SIP_APPLICATION_SDP);
273
+
271 274
   if(dlg.reply(req,183,"Session Progress",
272
-	       "application/sdp") != 0){
275
+	       &sdp_body) != 0){
273 276
     throw AmSession::Exception(500,"could not reply");
274 277
   } else {
275 278
     invite_req = req;
Browse code

adapt to new on[Early]SessionStart behavior

Raphael Coeffic authored on 14/07/2011 14:04:49
Showing 1 changed files
... ...
@@ -343,6 +343,8 @@ void EarlyAnnounceDialog::onEarlySessionStart()
343 343
     throw string("EarlyAnnounceDialog::onEarlySessionStart: Cannot open file");
344 344
     
345 345
   setOutput(&wav_file);
346
+
347
+  AmB2BCallerSession::onEarlySessionStart();
346 348
 }
347 349
 
348 350
 void EarlyAnnounceDialog::onBye(const AmSipRequest& req)
Browse code

wip: adds parsed session parameters extracted from the P-App-Param HF.

Raphael Coeffic authored on 25/05/2011 14:32:10
Showing 1 changed files
... ...
@@ -277,7 +277,8 @@ void EarlyAnnounceDialog::onInvite(const AmSipRequest& req)
277 277
 }
278 278
 
279 279
 
280
-AmSession* EarlyAnnounceFactory::onInvite(const AmSipRequest& req, const string& app_name)
280
+AmSession* EarlyAnnounceFactory::onInvite(const AmSipRequest& req, const string& app_name,
281
+					  const map<string,string>& app_params)
281 282
 {
282 283
 
283 284
 #ifdef USE_MYSQL
Browse code

propagate app_name to everywhere it is needed.

Raphael Coeffic authored on 10/05/2011 14:36:36
Showing 1 changed files
... ...
@@ -277,7 +277,7 @@ void EarlyAnnounceDialog::onInvite(const AmSipRequest& req)
277 277
 }
278 278
 
279 279
 
280
-AmSession* EarlyAnnounceFactory::onInvite(const AmSipRequest& req)
280
+AmSession* EarlyAnnounceFactory::onInvite(const AmSipRequest& req, const string& app_name)
281 281
 {
282 282
 
283 283
 #ifdef USE_MYSQL
Browse code

first load of fixes after merge from master.

Raphael Coeffic authored on 05/04/2011 14:12:22
Showing 1 changed files
... ...
@@ -350,7 +350,7 @@ void EarlyAnnounceDialog::onBye(const AmSipRequest& req)
350 350
   setStopped();
351 351
 }
352 352
 
353
-void EarlyAnnounceDialog::onCancel()
353
+void EarlyAnnounceDialog::onCancel(const AmSipRequest& req)
354 354
 {
355 355
   dlg.reply(invite_req,487,"Call terminated");
356 356
   setStopped();
Browse code

removed unnecessary err handling code

Stefan Sayer authored on 19/10/2010 18:02:24
Showing 1 changed files
... ...
@@ -268,21 +268,11 @@ int EarlyAnnounceFactory::onLoad()
268 268
 
269 269
 void EarlyAnnounceDialog::onInvite(const AmSipRequest& req) 
270 270
 {
271
-  try {
272
-    if(dlg.reply(req,183,"Session Progress",
273
-		 "application/sdp") != 0){
274
-
275
-      throw AmSession::Exception(500,"could not reply");
276
-    }
277
-    else {	    
278
-      invite_req = req;
279
-    }
280
-
281
-  } catch(const AmSession::Exception& e) {
282
-
283
-    ERROR("%i %s\n",e.code,e.reason.c_str());
284
-    setStopped();
285
-    AmSipDialog::reply_error(req,e.code,e.reason);
271
+  if(dlg.reply(req,183,"Session Progress",
272
+	       "application/sdp") != 0){
273
+    throw AmSession::Exception(500,"could not reply");
274
+  } else {
275
+    invite_req = req;
286 276
   }
287 277
 }
288 278
 
... ...
@@ -346,9 +336,10 @@ void EarlyAnnounceDialog::onEarlySessionStart()
346 336
   // this disables DTMF detection as well
347 337
   setReceiving(false);
348 338
 
349
-  DBG("EarlyAnnounceDialog::onSessionStart\n");
339
+  DBG("EarlyAnnounceDialog::onEarlySessionStart\n");
340
+
350 341
   if(wav_file.open(filename,AmAudioFile::Read))
351
-    throw string("EarlyAnnounceDialog::onSessionStart: Cannot open file\n");
342
+    throw string("EarlyAnnounceDialog::onEarlySessionStart: Cannot open file");
352 343
     
353 344
   setOutput(&wav_file);
354 345
 }
Browse code

fixed: early_announce

Raphael Coeffic authored on 19/10/2010 16:05:28
Showing 1 changed files
... ...
@@ -340,7 +340,7 @@ EarlyAnnounceDialog::~EarlyAnnounceDialog()
340 340
 {
341 341
 }
342 342
 
343
-void EarlyAnnounceDialog::onSessionStart(const AmSipRequest& req)
343
+void EarlyAnnounceDialog::onEarlySessionStart()
344 344
 {
345 345
   // we can drop all received packets
346 346
   // this disables DTMF detection as well
Browse code

Merge branch 'master' into offer_answer

Raphael Coeffic authored on 13/10/2010 14:04:23
Showing 0 changed files
Browse code

ported the first load of plug-ins (those which compile on osx).

Raphael Coeffic authored on 07/10/2010 18:34:03
Showing 1 changed files
... ...
@@ -271,12 +271,8 @@ int EarlyAnnounceFactory::onLoad()
271 271
 void EarlyAnnounceDialog::onInvite(const AmSipRequest& req) 
272 272
 {
273 273
   try {
274
-
275
-    string sdp_reply;
276
-    acceptAudio(req.body,req.hdrs,&sdp_reply);
277
-
278 274
     if(dlg.reply(req,183,"Session Progress",
279
-		 "application/sdp",sdp_reply) != 0){
275
+		 "application/sdp") != 0){
280 276
 
281 277
       throw AmSession::Exception(500,"could not reply");
282 278
     }
Browse code

added OpenSSL linking exception to license

Stefan Sayer authored on 23/09/2010 14:41:49
Showing 1 changed files
... ...
@@ -1,12 +1,10 @@
1 1
 /*
2
- * $Id$
3
- *
4 2
  * Copyright (C) 2002-2003 Fhg Fokus
5 3
  * Copyright (C) 2008 Juha Heinanen (USE_MYSQL parts)
6 4
  *
7
- * This file is part of sems, a free SIP media server.
5
+ * This file is part of SEMS, a free SIP media server.
8 6
  *
9
- * sems is free software; you can redistribute it and/or modify
7
+ * SEMS is free software; you can redistribute it and/or modify
10 8
  * it under the terms of the GNU General Public License as published by
11 9
  * the Free Software Foundation; either version 2 of the License, or
12 10
  * (at your option) any later version.
... ...
@@ -16,7 +14,7 @@
16 14
  * software, please contact iptel.org by e-mail at the following addresses:
17 15
  *    info@iptel.org
18 16
  *
19
- * sems is distributed in the hope that it will be useful,
17
+ * SEMS is distributed in the hope that it will be useful,
20 18
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 19
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 20
  * GNU General Public License for more details.
Browse code

getHeader:support content spanning multipe headers

Patch by Robert Szokovacs

Stefan Sayer authored on 01/07/2010 12:48:17
Showing 1 changed files
... ...
@@ -298,7 +298,7 @@ AmSession* EarlyAnnounceFactory::onInvite(const AmSipRequest& req)
298 298
 
299 299
 #ifdef USE_MYSQL
300 300
 
301
-    string iptel_app_param = getHeader(req.hdrs, PARAM_HDR);
301
+    string iptel_app_param = getHeader(req.hdrs, PARAM_HDR, true);
302 302
     string language = get_header_keyvalue(iptel_app_param,"Language");
303 303
     string announce_file = "";
304 304
 
... ...
@@ -385,11 +385,11 @@ void EarlyAnnounceDialog::process(AmEvent* event)
385 385
 	continue_b2b = true;
386 386
       } else if (EarlyAnnounceFactory::ContinueB2B == 
387 387
 		 EarlyAnnounceFactory::AppParam) {
388
-	string iptel_app_param = getHeader(invite_req.hdrs, PARAM_HDR);
388
+	string iptel_app_param = getHeader(invite_req.hdrs, PARAM_HDR, true);
389 389
 	if (iptel_app_param.length()) {
390 390
 	  continue_b2b = get_header_keyvalue(iptel_app_param,"B2B")=="yes";
391 391
 	} else {
392
-	  continue_b2b = getHeader(invite_req.hdrs,"P-B2B")=="yes";
392
+	  continue_b2b = getHeader(invite_req.hdrs,"P-B2B", true)=="yes";
393 393
 	}
394 394
       }
395 395
       DBG("determined: continue_b2b = %s\n", continue_b2b?"true":"false");
... ...
@@ -398,7 +398,7 @@ void EarlyAnnounceDialog::process(AmEvent* event)
398 398
 	unsigned int code_i = 404;
399 399
 	string reason = "Not Found";
400 400
 	
401
-	string iptel_app_param = getHeader(invite_req.hdrs, PARAM_HDR);
401
+	string iptel_app_param = getHeader(invite_req.hdrs, PARAM_HDR, true);
402 402
 	if (iptel_app_param.length()) {
403 403
 	  string code = get_header_keyvalue(iptel_app_param,"Final-Reply-Code");
404 404
 	  if (code.length() && str2i(code, code_i)) {
... ...
@@ -408,11 +408,11 @@ void EarlyAnnounceDialog::process(AmEvent* event)
408 408
 	  if (!reason.length())
409 409
 	    reason = "Not Found";
410 410
 	} else {
411
-	  string code = getHeader(invite_req.hdrs,"P-Final-Reply-Code");
411
+	  string code = getHeader(invite_req.hdrs,"P-Final-Reply-Code", true);
412 412
 	  if (code.length() && str2i(code, code_i)) {
413 413
 	    ERROR("while parsing P-Final-Reply-Code\n");
414 414
 	  }
415
-	  string h_reason =  getHeader(invite_req.hdrs,"P-Final-Reply-Reason");
415
+	  string h_reason =  getHeader(invite_req.hdrs,"P-Final-Reply-Reason", true);
416 416
 	  if (h_reason.length()) {
417 417
 	    INFO("Use of P-Final-Reply-Code/P-Final-Reply-Reason is deprecated. ");
418 418
 	    INFO("Use '%s: Final-Reply-Code=<code>;"
Browse code

Copy+paste typo: this conf-file actually is a early_announce.conf

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1941 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Peter Lemenkov authored on 02/06/2010 09:14:45
Showing 1 changed files
... ...
@@ -178,13 +178,13 @@ int EarlyAnnounceFactory::onLoad()
178 178
 
179 179
   mysql_user = cfg.getParameter("mysql_user");
180 180
   if (mysql_user.empty()) {
181
-    ERROR("conference.conf parameter 'mysql_user' is missing.\n");
181
+    ERROR("early_announce.conf parameter 'mysql_user' is missing.\n");
182 182
     return -1;
183 183
   }
184 184
 
185 185
   mysql_passwd = cfg.getParameter("mysql_passwd");
186 186
   if (mysql_passwd.empty()) {
187
-    ERROR("conference.conf parameter 'mysql_passwd' is missing.\n");
187
+    ERROR("early_announce.conf parameter 'mysql_passwd' is missing.\n");
188 188
     return -1;
189 189
   }
190 190
 
Browse code

Typo: paramater => parameter

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1940 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Peter Lemenkov authored on 02/06/2010 09:14:36
Showing 1 changed files
... ...
@@ -178,13 +178,13 @@ int EarlyAnnounceFactory::onLoad()
178 178
 
179 179
   mysql_user = cfg.getParameter("mysql_user");
180 180
   if (mysql_user.empty()) {
181
-    ERROR("conference.conf paramater 'mysql_user' is missing.\n");
181
+    ERROR("conference.conf parameter 'mysql_user' is missing.\n");
182 182
     return -1;
183 183
   }
184 184
 
185 185
   mysql_passwd = cfg.getParameter("mysql_passwd");
186 186
   if (mysql_passwd.empty()) {
187
-    ERROR("conference.conf paramater 'mysql_passwd' is missing.\n");
187
+    ERROR("conference.conf parameter 'mysql_passwd' is missing.\n");
188 188
     return -1;
189 189
   }
190 190
 
Browse code

* Now MySQL parts of early_announce and conference code work also with latest MySQL++ lib version 3.0.0.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1036 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Juha Heinanen authored on 12/07/2008 07:35:34
Showing 1 changed files
... ...
@@ -99,16 +99,26 @@ int get_announce_msg(string application, string message, string user,
99 99
 	DBG("Query string <%s>\n", query_string.c_str());
100 100
 
101 101
 	query << query_string;
102
+
103
+#ifdef VERSION2
102 104
 	mysqlpp::Result res = query.store();
105
+#else
106
+    	mysqlpp::StoreQueryResult res = query.store();
107
+#endif
103 108
 
104 109
 	mysqlpp::Row row;
105 110
 
106 111
 	if (res) {
107 112
 	    if ((res.num_rows() > 0) && (row = res.at(0))) {
108 113
 		FILE *file;
109
-		unsigned long length = row.raw_string(0).size();
110 114
 		file = fopen((*audio_file).c_str(), "wb");
115
+#ifdef VERSION2
116
+		unsigned long length = row.raw_string(0).size();
111 117
 		fwrite(row.at(0).data(), 1, length, file);
118
+#else
119
+		mysqlpp::String s = row[0];
120
+		fwrite(s.data(), 1, s.length(), file);
121
+#endif
112 122
 		fclose(file);
113 123
 		return 1;
114 124
 	    } else {
... ...
@@ -200,7 +210,11 @@ int EarlyAnnounceFactory::onLoad()
200 210
 
201 211
   try {
202 212
 
213
+#ifdef VERSION2
203 214
     Connection.set_option(Connection.opt_reconnect, true);
215
+#else
216
+    Connection.set_option(new mysqlpp::ReconnectOption(true));
217
+#endif
204 218
     Connection.connect(mysql_db.c_str(), mysql_server.c_str(),
205 219
 		       mysql_user.c_str(), mysql_passwd.c_str());
206 220
     if (!Connection) {
Browse code

simplified (AmB2BSession already has invite_req)

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@926 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 30/04/2008 17:16:23
Showing 1 changed files
... ...
@@ -266,9 +266,8 @@ void EarlyAnnounceDialog::onInvite(const AmSipRequest& req)
266 266
 
267 267
       throw AmSession::Exception(500,"could not reply");
268 268
     }
269
-    else {
270
-	    
271
-      localreq = req;
269
+    else {	    
270
+      invite_req = req;
272 271
     }
273 272
 
274 273
   } catch(const AmSession::Exception& e) {
... ...
@@ -354,7 +353,7 @@ void EarlyAnnounceDialog::onBye(const AmSipRequest& req)
354 353
 
355 354
 void EarlyAnnounceDialog::onCancel()
356 355
 {
357
-  dlg.reply(localreq,487,"Call terminated");
356
+  dlg.reply(invite_req,487,"Call terminated");
358 357
   setStopped();
359 358
 }
360 359
 
... ...
@@ -372,11 +371,11 @@ void EarlyAnnounceDialog::process(AmEvent* event)
372 371
 	continue_b2b = true;
373 372
       } else if (EarlyAnnounceFactory::ContinueB2B == 
374 373
 		 EarlyAnnounceFactory::AppParam) {
375
-	string iptel_app_param = getHeader(localreq.hdrs, PARAM_HDR);
374
+	string iptel_app_param = getHeader(invite_req.hdrs, PARAM_HDR);
376 375
 	if (iptel_app_param.length()) {
377 376
 	  continue_b2b = get_header_keyvalue(iptel_app_param,"B2B")=="yes";
378 377
 	} else {
379
-	  continue_b2b = getHeader(localreq.hdrs,"P-B2B")=="yes";
378
+	  continue_b2b = getHeader(invite_req.hdrs,"P-B2B")=="yes";
380 379
 	}
381 380
       }
382 381
       DBG("determined: continue_b2b = %s\n", continue_b2b?"true":"false");
... ...
@@ -385,7 +384,7 @@ void EarlyAnnounceDialog::process(AmEvent* event)
385 384
 	unsigned int code_i = 404;
386 385
 	string reason = "Not Found";
387 386
 	
388
-	string iptel_app_param = getHeader(localreq.hdrs, PARAM_HDR);
387
+	string iptel_app_param = getHeader(invite_req.hdrs, PARAM_HDR);
389 388
 	if (iptel_app_param.length()) {
390 389
 	  string code = get_header_keyvalue(iptel_app_param,"Final-Reply-Code");
391 390
 	  if (code.length() && str2i(code, code_i)) {
... ...
@@ -395,11 +394,11 @@ void EarlyAnnounceDialog::process(AmEvent* event)
395 394
 	  if (!reason.length())
396 395
 	    reason = "Not Found";
397 396
 	} else {
398
-	  string code = getHeader(localreq.hdrs,"P-Final-Reply-Code");
397
+	  string code = getHeader(invite_req.hdrs,"P-Final-Reply-Code");
399 398
 	  if (code.length() && str2i(code, code_i)) {
400 399
 	    ERROR("while parsing P-Final-Reply-Code\n");
401 400
 	  }
402
-	  string h_reason =  getHeader(localreq.hdrs,"P-Final-Reply-Reason");
401
+	  string h_reason =  getHeader(invite_req.hdrs,"P-Final-Reply-Reason");
403 402
 	  if (h_reason.length()) {
404 403
 	    INFO("Use of P-Final-Reply-Code/P-Final-Reply-Reason is deprecated. ");
405 404
 	    INFO("Use '%s: Final-Reply-Code=<code>;"
... ...
@@ -409,14 +408,14 @@ void EarlyAnnounceDialog::process(AmEvent* event)
409 408
 	}
410 409
 
411 410
 	DBG("Replying with code %d %s\n", code_i, reason.c_str());
412
-	dlg.reply(localreq, code_i, reason);
411
+	dlg.reply(invite_req, code_i, reason);
413 412
 	
414 413
 	setStopped();
415 414
       } else {
416 415
 	set_sip_relay_only(true);
417
-	recvd_req.insert(std::make_pair(localreq.cseq,localreq));
416
+	recvd_req.insert(std::make_pair(invite_req.cseq,invite_req));
418 417
 	
419
-	relayEvent(new B2BSipRequestEvent(localreq,true));
418
+	relayEvent(new B2BSipRequestEvent(invite_req,true));
420 419
       }
421 420
 	
422 421
       return;
Browse code

SEMS-30: continue_b2b=[yes|no|app-param]

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@924 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 30/04/2008 15:44:13
Showing 1 changed files
... ...
@@ -54,7 +54,8 @@ string EarlyAnnounceFactory::AnnouncePath;
54 54
 string EarlyAnnounceFactory::AnnounceFile;
55 55
 #endif
56 56
 
57
-bool EarlyAnnounceFactory::ContinueB2B = false;
57
+EarlyAnnounceFactory::ContB2B EarlyAnnounceFactory::ContinueB2B = 
58
+  EarlyAnnounceFactory::Never;
58 59
 
59 60
 EarlyAnnounceFactory::EarlyAnnounceFactory(const string& _app_name)
60 61
   : AmSessionFactory(_app_name)
... ...
@@ -140,10 +141,18 @@ int EarlyAnnounceFactory::onLoad()
140 141
   // get application specific global parameters
141 142
   configureModule(cfg);
142 143
 
143
-  if (cfg.hasParameter("continue_b2b") &&
144
-      cfg.getParameter("continue_b2b") == "yes") {
145
-    ContinueB2B = true;
146
-    DBG("early_announce in b2bua mode.\n");
144
+  if (cfg.hasParameter("continue_b2b")) { 
145
+    if (cfg.getParameter("continue_b2b") == "yes") {
146
+      ContinueB2B = Always;
147
+      DBG("early_announce in b2bua mode.\n");
148
+    }
149
+    else if (cfg.getParameter("continue_b2b") == "app-param") {
150
+      ContinueB2B = AppParam;
151
+      DBG("early_announce in b2bua/final reply mode "
152
+	  "(depends on app-param).\n");
153
+    } else {
154
+      DBG("early_announce sends final reply.\n");
155
+    }
147 156
   }
148 157
 
149 158
 #ifdef USE_MYSQL
... ...
@@ -354,11 +363,25 @@ void EarlyAnnounceDialog::process(AmEvent* event)
354 363
 
355 364
   AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event);
356 365
   if(audio_event && 
357
-     (audio_event->event_id == AmAudioEvent::cleared))
358
-    {
366
+     (audio_event->event_id == AmAudioEvent::cleared)) {
359 367
       DBG("AmAudioEvent::cleared\n");
360 368
 
361
-      if (!EarlyAnnounceFactory::ContinueB2B) {
369
+      bool continue_b2b = false;
370
+      if (EarlyAnnounceFactory::ContinueB2B == 
371
+	  EarlyAnnounceFactory::Always) {
372
+	continue_b2b = true;
373
+      } else if (EarlyAnnounceFactory::ContinueB2B == 
374
+		 EarlyAnnounceFactory::AppParam) {
375
+	string iptel_app_param = getHeader(localreq.hdrs, PARAM_HDR);
376
+	if (iptel_app_param.length()) {
377
+	  continue_b2b = get_header_keyvalue(iptel_app_param,"B2B")=="yes";
378
+	} else {
379
+	  continue_b2b = getHeader(localreq.hdrs,"P-B2B")=="yes";
380
+	}
381
+      }
382
+      DBG("determined: continue_b2b = %s\n", continue_b2b?"true":"false");
383
+
384
+      if (!continue_b2b) {
362 385
 	unsigned int code_i = 404;
363 386
 	string reason = "Not Found";
364 387
 	
... ...
@@ -369,6 +392,8 @@ void EarlyAnnounceDialog::process(AmEvent* event)
369 392
 	    ERROR("while parsing Final-Reply-Code parameter\n");
370 393
 	  }
371 394
 	  reason = get_header_keyvalue(iptel_app_param,"Final-Reply-Reason");
395
+	  if (!reason.length())
396
+	    reason = "Not Found";
372 397
 	} else {
373 398
 	  string code = getHeader(localreq.hdrs,"P-Final-Reply-Code");
374 399
 	  if (code.length() && str2i(code, code_i)) {
Browse code

* Set reconnect option so that MySQL connection is automatically restored in case of server restart.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@821 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Juha Heinanen authored on 24/03/2008 13:29:21
Showing 1 changed files
... ...
@@ -191,6 +191,7 @@ int EarlyAnnounceFactory::onLoad()
191 191
 
192 192
   try {
193 193
 
194
+    Connection.set_option(Connection.opt_reconnect, true);
194 195
     Connection.connect(mysql_db.c_str(), mysql_server.c_str(),
195 196
 		       mysql_user.c_str(), mysql_passwd.c_str());
196 197
     if (!Connection) {
... ...
@@ -198,7 +199,12 @@ int EarlyAnnounceFactory::onLoad()
198 199
       return -1;
199 200
     }
200 201
   }
201
-	
202
+
203
+  catch (const mysqlpp::BadOption& er) {
204
+    ERROR("MySQL++ set_option error: %s\n", er.what());
205
+    return -1;
206
+  }
207
+ 	
202 208
   catch (const mysqlpp::Exception& er) {
203 209
     // Catch-all for any MySQL++ exceptions
204 210
     ERROR("MySQL++ error: %s\n", er.what());
Browse code

early media announcement with call continuation in b2b mode option

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@812 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 18/03/2008 15:22:29
Showing 1 changed files
... ...
@@ -54,6 +54,8 @@ string EarlyAnnounceFactory::AnnouncePath;
54 54
 string EarlyAnnounceFactory::AnnounceFile;
55 55
 #endif
56 56
 
57
+bool EarlyAnnounceFactory::ContinueB2B = false;
58
+
57 59
 EarlyAnnounceFactory::EarlyAnnounceFactory(const string& _app_name)
58 60
   : AmSessionFactory(_app_name)
59 61
 {
... ...
@@ -138,6 +140,12 @@ int EarlyAnnounceFactory::onLoad()
138 140
   // get application specific global parameters
139 141
   configureModule(cfg);
140 142
 
143
+  if (cfg.hasParameter("continue_b2b") &&
144
+      cfg.getParameter("continue_b2b") == "yes") {
145
+    ContinueB2B = true;
146
+    DBG("early_announce in b2bua mode.\n");
147
+  }
148
+
141 149
 #ifdef USE_MYSQL
142 150
 
143 151
   /* Get default audio from MySQL */
... ...
@@ -303,6 +311,7 @@ AmSession* EarlyAnnounceFactory::onInvite(const AmSipRequest& req)
303 311
 EarlyAnnounceDialog::EarlyAnnounceDialog(const string& filename)
304 312
   : filename(filename)
305 313
 {
314
+  set_sip_relay_only(false);
306 315
 }
307 316
 
308 317
 EarlyAnnounceDialog::~EarlyAnnounceDialog()
... ...
@@ -342,37 +351,45 @@ void EarlyAnnounceDialog::process(AmEvent* event)
342 351
      (audio_event->event_id == AmAudioEvent::cleared))
343 352
     {
344 353
       DBG("AmAudioEvent::cleared\n");
345
-      unsigned int code_i = 404;
346
-      string reason = "Not Found";
347
-
348
-      string iptel_app_param = getHeader(localreq.hdrs, PARAM_HDR);
349
-      if (iptel_app_param.length()) {
350
-	string code = get_header_keyvalue(iptel_app_param,"Final-Reply-Code");
351
-	if (code.length() && str2i(code, code_i)) {
352
-	  ERROR("while parsing Final-Reply-Code parameter\n");
353
-	}
354
-	reason = get_header_keyvalue(iptel_app_param,"Final-Reply-Reason");
355
-      } else {
356
-	string code = getHeader(localreq.hdrs,"P-Final-Reply-Code");
357
-	if (code.length() && str2i(code, code_i)) {
358
-	  ERROR("while parsing P-Final-Reply-Code\n");
359
-	}
360
-	string h_reason =  getHeader(localreq.hdrs,"P-Final-Reply-Reason");
361
-	if (h_reason.length()) {
362
-	  INFO("Use of P-Final-Reply-Code/P-Final-Reply-Reason is deprecated. ");
363
-	  INFO("Use '%s: Final-Reply-Code=<code>;"
364
-	       "Final-Reply-Reason=<rs>' instead.\n",PARAM_HDR);
365
-	  reason = h_reason;
354
+
355
+      if (!EarlyAnnounceFactory::ContinueB2B) {
356
+	unsigned int code_i = 404;
357
+	string reason = "Not Found";
358
+	
359
+	string iptel_app_param = getHeader(localreq.hdrs, PARAM_HDR);
360
+	if (iptel_app_param.length()) {
361
+	  string code = get_header_keyvalue(iptel_app_param,"Final-Reply-Code");
362
+	  if (code.length() && str2i(code, code_i)) {
363
+	    ERROR("while parsing Final-Reply-Code parameter\n");
364
+	  }
365
+	  reason = get_header_keyvalue(iptel_app_param,"Final-Reply-Reason");
366
+	} else {
367
+	  string code = getHeader(localreq.hdrs,"P-Final-Reply-Code");
368
+	  if (code.length() && str2i(code, code_i)) {
369
+	    ERROR("while parsing P-Final-Reply-Code\n");
370
+	  }
371
+	  string h_reason =  getHeader(localreq.hdrs,"P-Final-Reply-Reason");
372
+	  if (h_reason.length()) {
373
+	    INFO("Use of P-Final-Reply-Code/P-Final-Reply-Reason is deprecated. ");
374
+	    INFO("Use '%s: Final-Reply-Code=<code>;"
375
+		 "Final-Reply-Reason=<rs>' instead.\n",PARAM_HDR);
376
+	    reason = h_reason;
377
+	  }
366 378
 	}
367
-      }
368 379
 
369
-      DBG("Replying with code %d %s\n", code_i, reason.c_str());
370
-      dlg.reply(localreq, code_i, reason);
380
+	DBG("Replying with code %d %s\n", code_i, reason.c_str());
381
+	dlg.reply(localreq, code_i, reason);
371 382
 	
372
-      setStopped();
383
+	setStopped();
384
+      } else {
385
+	set_sip_relay_only(true);
386
+	recvd_req.insert(std::make_pair(localreq.cseq,localreq));
387
+	
388
+	relayEvent(new B2BSipRequestEvent(localreq,true));
389
+      }
373 390
 	
374 391
       return;
375 392
     }
376 393
 
377
-  AmSession::process(event);
394
+  AmB2BCallerSession::process(event);
378 395
 }
Browse code

* Added MYSQL support to early announce application.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@719 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Juha Heinanen authored on 12/02/2008 02:59:53
Showing 1 changed files
... ...
@@ -2,6 +2,7 @@
2 2
  * $Id$
3 3
  *
4 4
  * Copyright (C) 2002-2003 Fhg Fokus
5
+ * Copyright (C) 2008 Juha Heinanen (USE_MYSQL parts)
5 6
  *
6 7
  * This file is part of sems, a free SIP media server.
7 8
  *
... ...
@@ -34,16 +35,100 @@
34 35
 
35 36
 #define MOD_NAME "early_announce"
36 37
 
38
+#ifdef USE_MYSQL
39
+#include <mysql++/mysql++.h>
40
+#include <stdio.h>
41
+#define DEFAULT_AUDIO_TABLE "default_audio"
42
+#define DOMAIN_AUDIO_TABLE "domain_audio"
43
+#define USER_AUDIO_TABLE "user_audio"
44
+#endif
45
+
37 46
 EXPORT_SESSION_FACTORY(EarlyAnnounceFactory,MOD_NAME);
38 47
 
48
+#ifdef USE_MYSQL
49
+string EarlyAnnounceFactory::AnnounceApplication;
50
+string EarlyAnnounceFactory::AnnounceMessage;
51
+string EarlyAnnounceFactory::DefaultLanguage;
52
+#else
39 53
 string EarlyAnnounceFactory::AnnouncePath;
40 54
 string EarlyAnnounceFactory::AnnounceFile;
55
+#endif
41 56
 
42 57
 EarlyAnnounceFactory::EarlyAnnounceFactory(const string& _app_name)
43 58
   : AmSessionFactory(_app_name)
44 59
 {
45 60
 }
46 61
 
62
+#ifdef USE_MYSQL
63
+mysqlpp::Connection EarlyAnnounceFactory::Connection(mysqlpp::use_exceptions);
64
+
65
+int get_announce_msg(string application, string message, string user,
66
+		     string domain, string language, string *audio_file)
67
+{
68
+    string query_string;
69
+
70
+    if (!user.empty()) {
71
+	*audio_file = string("/tmp/") +  application + "_" + 
72
+	    message + "_" + domain + "_" + user + ".wav";
73
+	query_string = "select audio from " + string(USER_AUDIO_TABLE) +
74
+	    " where application='" + application + "' and message='" +
75
+	    message + "' and userid='" + user + "' and domain='" +
76
+	    domain + "'";
77
+    } else if (!domain.empty()) {
78
+	*audio_file = string("/tmp/") +  application + "_" +
79
+	    message + "_" + domain + "_" + language + ".wav";
80
+	query_string = "select audio from " + string(DOMAIN_AUDIO_TABLE) +
81
+	    " where application='" + application + "' and message='" +
82
+	    message + "' and domain='" + domain + "' and language='" +
83
+	    language + "'";
84
+    } else {
85
+	*audio_file = string("/tmp/") +  application  + "_" +
86
+	    message + "_" + language + ".wav";
87
+	query_string = "select audio from " + string(DEFAULT_AUDIO_TABLE) +
88
+	    " where application='" + application + "' and message='" +
89
+	    message + "' and language='" + language + "'";
90
+    }
91
+
92
+    try {
93
+
94
+	mysqlpp::Query query = EarlyAnnounceFactory::Connection.query();
95
+	    
96
+	DBG("Query string <%s>\n", query_string.c_str());
97
+
98
+	query << query_string;
99
+	mysqlpp::Result res = query.store();
100
+
101
+	mysqlpp::Row row;
102
+
103
+	if (res) {
104
+	    if ((res.num_rows() > 0) && (row = res.at(0))) {
105
+		FILE *file;
106
+		unsigned long length = row.raw_string(0).size();
107
+		file = fopen((*audio_file).c_str(), "wb");
108
+		fwrite(row.at(0).data(), 1, length, file);
109
+		fclose(file);
110
+		return 1;
111
+	    } else {
112
+		*audio_file = "";
113
+		return 1;
114
+	    }
115
+	} else {
116
+	    ERROR("Database query error\n");
117
+	    *audio_file = "";
118
+	    return 0;
119
+	}
120
+    }
121
+
122
+    catch (const mysqlpp::Exception& er) {
123
+	// Catch-all for any MySQL++ exceptions
124
+	ERROR("MySQL++ error: %s\n", er.what());
125
+	*audio_file = "";
126
+	return 0;
127
+    }
128
+}
129
+
130
+#endif
131
+
47 132
 int EarlyAnnounceFactory::onLoad()
48 133
 {
49 134
   AmConfigReader cfg;
... ...
@@ -53,6 +138,79 @@ int EarlyAnnounceFactory::onLoad()
53 138
   // get application specific global parameters
54 139
   configureModule(cfg);
55 140
 
141
+#ifdef USE_MYSQL
142
+
143
+  /* Get default audio from MySQL */
144
+
145
+  string mysql_server, mysql_user, mysql_passwd, mysql_db;
146
+
147
+  mysql_server = cfg.getParameter("mysql_server");
148
+  if (mysql_server.empty()) {
149
+    mysql_server = "localhost";
150
+  }
151
+
152
+  mysql_user = cfg.getParameter("mysql_user");
153
+  if (mysql_user.empty()) {
154
+    ERROR("conference.conf paramater 'mysql_user' is missing.\n");
155
+    return -1;
156
+  }
157
+
158
+  mysql_passwd = cfg.getParameter("mysql_passwd");
159
+  if (mysql_passwd.empty()) {
160
+    ERROR("conference.conf paramater 'mysql_passwd' is missing.\n");
161
+    return -1;
162
+  }
163
+
164
+  mysql_db = cfg.getParameter("mysql_db");
165
+  if (mysql_db.empty()) {
166
+    mysql_db = "sems";
167
+  }
168
+
169
+  AnnounceApplication = cfg.getParameter("application");
170
+  if (AnnounceApplication.empty()) {
171
+    AnnounceApplication = MOD_NAME;
172
+  }
173
+
174
+  AnnounceMessage = cfg.getParameter("message");
175
+  if (AnnounceMessage.empty()) {
176
+    AnnounceMessage = "greeting_msg";
177
+  }
178
+
179
+  DefaultLanguage = cfg.getParameter("default_language");
180
+  if (DefaultLanguage.empty()) {
181
+    DefaultLanguage = "en";
182
+  }
183
+
184
+  try {
185
+
186
+    Connection.connect(mysql_db.c_str(), mysql_server.c_str(),
187
+		       mysql_user.c_str(), mysql_passwd.c_str());
188
+    if (!Connection) {
189
+      ERROR("Database connection failed: %s\n", Connection.error());
190
+      return -1;
191
+    }
192
+  }
193
+	
194
+  catch (const mysqlpp::Exception& er) {
195
+    // Catch-all for any MySQL++ exceptions
196
+    ERROR("MySQL++ error: %s\n", er.what());
197
+    return -1;
198
+  }
199
+
200
+  string announce_file;
201
+  if (!get_announce_msg(AnnounceApplication, AnnounceMessage, "", "",
202
+			DefaultLanguage, &announce_file)) {
203
+    return -1;
204
+  }
205
+  if (announce_file.empty()) {
206
+    ERROR("default announce for " MOD_NAME " module does not exist.\n");
207
+    return -1;
208
+  }
209
+
210
+#else 
211
+
212
+  /* Get default audio from file system */
213
+
56 214
   AnnouncePath = cfg.getParameter("announce_path",ANNOUNCE_PATH);
57 215
   if( !AnnouncePath.empty() 
58 216
       && AnnouncePath[AnnouncePath.length()-1] != '/' )
... ...
@@ -67,6 +225,8 @@ int EarlyAnnounceFactory::onLoad()
67 225
     return -1;
68 226
   }
69 227
 
228
+#endif
229
+
70 230
   return 0;
71 231
 }
72 232
 
... ...
@@ -99,6 +259,26 @@ void EarlyAnnounceDialog::onInvite(const AmSipRequest& req)
99 259
 
100 260
 AmSession* EarlyAnnounceFactory::onInvite(const AmSipRequest& req)
101 261
 {
262
+
263
+#ifdef USE_MYSQL
264
+
265
+    string iptel_app_param = getHeader(req.hdrs, PARAM_HDR);
266
+    string language = get_header_keyvalue(iptel_app_param,"Language");
267
+    string announce_file = "";
268
+
269
+    if (language.empty()) language = DefaultLanguage;
270
+
271
+    get_announce_msg(AnnounceApplication, AnnounceMessage, req.user,
272
+		     req.domain, "", &announce_file);
273
+    if (!announce_file.empty()) goto end;
274
+    get_announce_msg(AnnounceApplication, AnnounceMessage, "", req.domain,
275
+		     language, &announce_file);
276
+    if (!announce_file.empty()) goto end;
277
+    get_announce_msg(AnnounceApplication, AnnounceMessage, "", "", language,
278
+		     &announce_file);
279
+
280
+#else
281
+
102 282
   string announce_path = AnnouncePath;
103 283
   string announce_file = announce_path + req.domain 
104 284
     + "/" + req.user + ".wav";
... ...
@@ -113,7 +293,9 @@ AmSession* EarlyAnnounceFactory::onInvite(const AmSipRequest& req)
113 293
     goto end;
114 294
 
115 295
   announce_file = AnnouncePath + AnnounceFile;
116
-    
296
+
297
+#endif
298
+
117 299
  end:
118 300
   return new EarlyAnnounceDialog(announce_file);
119 301
 }
... ...
@@ -175,7 +357,6 @@ void EarlyAnnounceDialog::process(AmEvent* event)
175 357
 	if (code.length() && str2i(code, code_i)) {
176 358
 	  ERROR("while parsing P-Final-Reply-Code\n");
177 359
 	}
178
-
179 360
 	string h_reason =  getHeader(localreq.hdrs,"P-Final-Reply-Reason");
180 361
 	if (h_reason.length()) {
181 362
 	  INFO("Use of P-Final-Reply-Code/P-Final-Reply-Reason is deprecated. ");
... ...
@@ -195,4 +376,3 @@ void EarlyAnnounceDialog::process(AmEvent* event)
195 376
 
196 377
   AmSession::process(event);
197 378
 }
198
-
Browse code

* Search for file to play now corresponds to documentation.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@556 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Juha Heinanen authored on 17/11/2007 01:45:18
Showing 1 changed files
... ...
@@ -101,7 +101,7 @@ AmSession* EarlyAnnounceFactory::onInvite(const AmSipRequest& req)
101 101
 {
102 102
   string announce_path = AnnouncePath;
103 103
   string announce_file = announce_path + req.domain 
104
-    + "/" + get_header_param(req.r_uri, "play") + ".wav";
104
+    + "/" + req.user + ".wav";
105 105
 
106 106
   DBG("trying '%s'\n",announce_file.c_str());
107 107
   if(file_exists(announce_file))
Browse code

indented apps to default indentation

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@433 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 29/08/2007 20:17:38
Showing 1 changed files
... ...
@@ -46,80 +46,80 @@ EarlyAnnounceFactory::EarlyAnnounceFactory(const string& _app_name)
46 46
 
47 47
 int EarlyAnnounceFactory::onLoad()
48 48
 {
49
-    AmConfigReader cfg;
50
-    if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
51
-	return -1;
49
+  AmConfigReader cfg;
50
+  if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
51
+    return -1;
52 52
 
53
-    // get application specific global parameters
54
-    configureModule(cfg);
53
+  // get application specific global parameters
54
+  configureModule(cfg);
55 55
 
56
-    AnnouncePath = cfg.getParameter("announce_path",ANNOUNCE_PATH);
57
-    if( !AnnouncePath.empty() 
58
-	&& AnnouncePath[AnnouncePath.length()-1] != '/' )
59
-	AnnouncePath += "/";
56
+  AnnouncePath = cfg.getParameter("announce_path",ANNOUNCE_PATH);
57
+  if( !AnnouncePath.empty() 
58
+      && AnnouncePath[AnnouncePath.length()-1] != '/' )
59
+    AnnouncePath += "/";
60 60
 
61
-    AnnounceFile = cfg.getParameter("default_announce",ANNOUNCE_FILE);
61
+  AnnounceFile = cfg.getParameter("default_announce",ANNOUNCE_FILE);
62 62
 
63
-    string announce_file = AnnouncePath + AnnounceFile;
64
-    if(!file_exists(announce_file)){
65
-	ERROR("default file for " MOD_NAME " module does not exist ('%s').\n",
66
-	      announce_file.c_str());
67
-	return -1;
68
-    }
63
+  string announce_file = AnnouncePath + AnnounceFile;
64
+  if(!file_exists(announce_file)){
65
+    ERROR("default file for " MOD_NAME " module does not exist ('%s').\n",
66
+	  announce_file.c_str());
67
+    return -1;
68
+  }
69 69
 
70
-    return 0;
70
+  return 0;
71 71
 }
72 72
 
73 73
 
74 74
 void EarlyAnnounceDialog::onInvite(const AmSipRequest& req) 
75 75
 {
76
-    try {
76
+  try {
77 77
 
78
-	string sdp_reply;
79
-	acceptAudio(req.body,req.hdrs,&sdp_reply);
78
+    string sdp_reply;
79
+    acceptAudio(req.body,req.hdrs,&sdp_reply);
80 80
 
81
-	if(dlg.reply(req,183,"Session Progress",
82
-		     "application/sdp",sdp_reply) != 0){
81
+    if(dlg.reply(req,183,"Session Progress",
82
+		 "application/sdp",sdp_reply) != 0){
83 83
 
84
-	    throw AmSession::Exception(500,"could not reply");
85
-	}
86
-	else {
84
+      throw AmSession::Exception(500,"could not reply");
85
+    }
86
+    else {
87 87
 	    
88
-	    localreq = req;
89
-	}
88
+      localreq = req;
89
+    }
90 90
 
91
-    } catch(const AmSession::Exception& e) {
91
+  } catch(const AmSession::Exception& e) {
92 92
 
93
-	ERROR("%i %s\n",e.code,e.reason.c_str());
94
-	setStopped();
95
-	AmSipDialog::reply_error(req,e.code,e.reason);
96
-    }