Browse code

changed sip dialog attribute in AmSession into a pointer.

Raphael Coeffic authored on 07/01/2013 16:27:13
Showing 39 changed files
... ...
@@ -171,19 +171,19 @@ void AnnounceTransferDialog::onSipRequest(const AmSipRequest& req)
171 171
       if ((code >= 200)&&(code < 300)) {
172 172
 	if (status != Hangup) {
173 173
 	  status = Hangup;
174
-	  dlg.bye();
174
+	  dlg->bye();
175 175
 	}
176 176
 	DBG("refer succeeded... stop session\n");
177 177
 	setStopped();
178 178
       } else if (code > 300) {
179 179
 	DBG("refer failed...\n");
180 180
 	if (status != Hangup) 
181
-	  dlg.bye();
181
+	  dlg->bye();
182 182
 	setStopped();
183 183
       }
184
-      dlg.reply(req, 200, "OK", NULL);
184
+      dlg->reply(req, 200, "OK", NULL);
185 185
     } catch (const AmSession::Exception& e) {
186
-      dlg.reply(req, e.code, e.reason, NULL);
186
+      dlg->reply(req, e.code, e.reason, NULL);
187 187
     }
188 188
   } else {
189 189
     AmSession::onSipRequest(req);
... ...
@@ -198,7 +198,7 @@ void AnnounceTransferDialog::onSipReply(const AmSipRequest& req,
198 198
       req.method == SIP_METH_REFER) {
199 199
     if (rep.code >= 300) {
200 200
       DBG("refer not accepted, stop session.\n");
201
-      dlg.bye();
201
+      dlg->bye();
202 202
       setStopped();
203 203
     }
204 204
   }
... ...
@@ -225,7 +225,7 @@ void AnnounceTransferDialog::process(AmEvent* event)
225 225
 	
226 226
   if(audio_event && (audio_event->event_id == AmAudioEvent::cleared) 
227 227
      && (status == Announcing)){
228
-    dlg.refer(callee_uri);
228
+    dlg->refer(callee_uri);
229 229
     status = Transfering;
230 230
     return;
231 231
   }
... ...
@@ -155,7 +155,7 @@ void AnnouncementDialog::process(AmEvent* event)
155 155
 
156 156
   AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event);
157 157
   if(audio_event && (audio_event->event_id == AmAudioEvent::cleared)){
158
-    dlg.bye();
158
+    dlg->bye();
159 159
     setStopped();
160 160
     return;
161 161
   }
... ...
@@ -299,7 +299,7 @@ void AnnRecorderDialog::onDtmf(int event, int duration_msec) {
299 299
     if(wav_file.open(msg_filename,AmAudioFile::Write,false)) {
300 300
      ERROR("AnnRecorder: couldn't open %s for writing\n", 
301 301
 	   msg_filename.c_str());
302
-     dlg.bye();
302
+     dlg->bye();
303 303
      setStopped();
304 304
     }
305 305
     wav_file.setRecordTime(MAX_MESSAGE_TIME*1000);
... ...
@@ -382,7 +382,7 @@ void AnnRecorderDialog::process(AmEvent* event)
382 382
   if(audio_event && (audio_event->event_id == AmAudioEvent::noAudio)){
383 383
 
384 384
     if (S_BYE == state) {
385
-      dlg.bye();
385
+      dlg->bye();
386 386
       setStopped();
387 387
       return;
388 388
     }
... ...
@@ -248,7 +248,7 @@ void CallBackDialog::onInvite(const AmSipRequest& req)
248 248
 
249 249
   ERROR("incoming calls not supported!\n");
250 250
   setStopped();
251
-  dlg.bye();
251
+  dlg->bye();
252 252
 }
253 253
 
254 254
 void CallBackDialog::onSessionStart() 
... ...
@@ -184,7 +184,7 @@ AmB2BCallerSession()
184 184
 void C2DCallerDialog::onInvite(const AmSipRequest& req)
185 185
 {
186 186
   ERROR("incoming calls not supported in click2dial app!\n");
187
-  dlg.reply(req,606,"Not Acceptable");
187
+  dlg->reply(req,606,"Not Acceptable");
188 188
   setStopped();
189 189
 }
190 190
 
... ...
@@ -245,15 +245,15 @@ void C2DCallerDialog::createCalleeSession()
245 245
   }
246 246
 
247 247
   AmB2BCalleeSession* callee_session = new C2DCalleeDialog(this, c);
248
-  AmSipDialog& callee_dlg = callee_session->dlg;
248
+  AmSipDialog* callee_dlg = callee_session->dlg;
249 249
 
250 250
   other_id = AmSession::getNewId();
251 251
 
252
-  callee_dlg.local_tag    = other_id;
253
-  callee_dlg.callid       = AmSession::getNewId();
254
-  callee_dlg.local_party  = dlg.local_party;
255
-  callee_dlg.remote_party = dlg.remote_party;
256
-  callee_dlg.remote_uri   = dlg.remote_uri;
252
+  callee_dlg->local_tag    = other_id;
253
+  callee_dlg->callid       = AmSession::getNewId();
254
+  callee_dlg->local_party  = dlg->local_party;
255
+  callee_dlg->remote_party = dlg->remote_party;
256
+  callee_dlg->remote_uri   = dlg->remote_uri;
257 257
 
258 258
   callee_session->start();
259 259
 
... ...
@@ -361,11 +361,11 @@ AmSession* ConferenceFactory::onRefer(const AmSipRequest& req, const string& app
361 361
     throw AmSession::Exception(488,"Not accepted here");
362 362
 
363 363
   AmSession* s = new ConferenceDialog(req.user);
364
-  s->dlg.local_tag  = req.from_tag;
364
+  s->dlg->local_tag  = req.from_tag;
365 365
   
366 366
   setupSessionTimer(s);
367 367
 
368
-  DBG("ConferenceFactory::onRefer: local_tag = %s\n",s->dlg.local_tag.c_str());
368
+  DBG("ConferenceFactory::onRefer: local_tag = %s\n",s->dlg->local_tag.c_str());
369 369
 
370 370
   return s;
371 371
 }
... ...
@@ -407,7 +407,7 @@ void ConferenceDialog::onStart() {
407 407
 
408 408
 void ConferenceDialog::onInvite(const AmSipRequest& req)
409 409
 {
410
-  if(dlg.getStatus() == AmSipDialog::Connected){
410
+  if(dlg->getStatus() == AmSipDialog::Connected){
411 411
     AmSession::onInvite(req);  
412 412
     return;
413 413
   }
... ...
@@ -637,7 +637,7 @@ void ConferenceDialog::process(AmEvent* ev)
637 637
 	
638 638
       case DoConfDisconnect:
639 639
 		
640
-	dlg.bye();
640
+	dlg->bye();
641 641
 	closeChannels();
642 642
 	setStopped();
643 643
 	break;
... ...
@@ -716,7 +716,7 @@ void ConferenceDialog::onDtmf(int event, int duration)
716 716
   DBG("ConferenceDialog::onDtmf\n");
717 717
   if (dialedout || !allow_dialout ||
718 718
       ((ConferenceFactory::MaxParticipants > 0) &&
719
-       (AmConferenceStatus::getConferenceSize(dlg.user) >= 
719
+       (AmConferenceStatus::getConferenceSize(dlg->user) >= 
720 720
 	ConferenceFactory::MaxParticipants)))
721 721
     return;
722 722
 
... ...
@@ -809,20 +809,20 @@ void ConferenceDialog::createDialoutParticipant(const string& uri_user)
809 809
 
810 810
   ConferenceFactory::setupSessionTimer(dialout_session);
811 811
 
812
-  AmSipDialog& dialout_dlg = dialout_session->dlg;
812
+  AmSipDialog* dialout_dlg = dialout_session->dlg;
813 813
 
814
-  dialout_dlg.local_tag    = dialout_id;
815
-  dialout_dlg.callid       = AmSession::getNewId();
814
+  dialout_dlg->local_tag    = dialout_id;
815
+  dialout_dlg->callid       = AmSession::getNewId();
816 816
 
817 817
   if (from_header.length() > 0) {
818
-    dialout_dlg.local_party  = from_header;
818
+    dialout_dlg->local_party  = from_header;
819 819
   } else {
820
-    dialout_dlg.local_party  = dlg.local_party;
820
+    dialout_dlg->local_party  = dlg->local_party;
821 821
   }
822
-  dialout_dlg.remote_party = uri;
823
-  dialout_dlg.remote_uri   = uri;
822
+  dialout_dlg->remote_party = uri;
823
+  dialout_dlg->remote_uri   = uri;
824 824
 
825
-  dialout_dlg.sendRequest(SIP_METH_INVITE,NULL,
825
+  dialout_dlg->sendRequest(SIP_METH_INVITE,NULL,
826 826
 			  extra_headers);
827 827
 
828 828
   dialout_session->start();
... ...
@@ -882,30 +882,30 @@ void ConferenceDialog::closeChannels()
882 882
 void ConferenceDialog::onSipRequest(const AmSipRequest& req)
883 883
 {
884 884
   AmSession::onSipRequest(req);
885
-  if((dlg.getStatus() >= AmSipDialog::Connected) ||
885
+  if((dlg->getStatus() >= AmSipDialog::Connected) ||
886 886
      (req.method != "REFER"))
887 887
     return;
888 888
 
889
-  std::swap(dlg.local_party,dlg.remote_party);
890
-  dlg.remote_tag = "";
889
+  std::swap(dlg->local_party,dlg->remote_party);
890
+  dlg->remote_tag = "";
891 891
 
892 892
   // get route set and next hop
893 893
   string iptel_app_param = getHeader(req.hdrs, PARAM_HDR, true);
894 894
   if (iptel_app_param.length()) {
895
-    dlg.route = get_header_keyvalue(iptel_app_param,"Transfer-RR");
895
+    dlg->route = get_header_keyvalue(iptel_app_param,"Transfer-RR");
896 896
   } else {
897 897
     INFO("Use of P-Transfer-RR/P-Transfer-NH is deprecated. "
898 898
 	 "Use '%s: Transfer-RR=<rr>;Transfer-NH=<nh>' instead.\n",PARAM_HDR);
899 899
 
900
-    dlg.route = getHeader(req.hdrs,"P-Transfer-RR", true);
900
+    dlg->route = getHeader(req.hdrs,"P-Transfer-RR", true);
901 901
   }
902 902
 
903
-  DBG("ConferenceDialog::onSipRequest: local_party = %s\n",dlg.local_party.c_str());
904
-  DBG("ConferenceDialog::onSipRequest: local_tag = %s\n",dlg.local_tag.c_str());
905
-  DBG("ConferenceDialog::onSipRequest: remote_party = %s\n",dlg.remote_party.c_str());
906
-  DBG("ConferenceDialog::onSipRequest: remote_tag = %s\n",dlg.remote_tag.c_str());
903
+  DBG("ConferenceDialog::onSipRequest: local_party = %s\n",dlg->local_party.c_str());
904
+  DBG("ConferenceDialog::onSipRequest: local_tag = %s\n",dlg->local_tag.c_str());
905
+  DBG("ConferenceDialog::onSipRequest: remote_party = %s\n",dlg->remote_party.c_str());
906
+  DBG("ConferenceDialog::onSipRequest: remote_tag = %s\n",dlg->remote_tag.c_str());
907 907
 
908
-  dlg.sendRequest(SIP_METH_INVITE);
908
+  dlg->sendRequest(SIP_METH_INVITE);
909 909
 
910 910
   transfer_req.reset(new AmSipRequest(req));
911 911
 
... ...
@@ -919,7 +919,7 @@ void ConferenceDialog::onSipReply(const AmSipRequest& req,
919 919
   AmSession::onSipReply(req, reply, old_dlg_status);
920 920
 
921 921
   DBG("ConferenceDialog::onSipReply: code = %i, reason = %s\n, status = %i\n",
922
-      reply.code,reply.reason.c_str(),dlg.getStatus());
922
+      reply.code,reply.reason.c_str(),dlg->getStatus());
923 923
     
924 924
   if(!dialedout /*&& !transfer_req.get()*/)
925 925
     return;
... ...
@@ -927,7 +927,7 @@ void ConferenceDialog::onSipReply(const AmSipRequest& req,
927 927
   if((old_dlg_status < AmSipDialog::Connected) &&
928 928
      (reply.cseq_method == SIP_METH_INVITE)){
929 929
 
930
-    switch(dlg.getStatus()){
930
+    switch(dlg->getStatus()){
931 931
 
932 932
     case AmSipDialog::Proceeding:
933 933
     case AmSipDialog::Early:
... ...
@@ -964,7 +964,7 @@ void ConferenceDialog::onSipReply(const AmSipRequest& req,
964 964
 
965 965
       // }
966 966
       // else {
967
-      // 	dlg.reply(*(transfer_req.get()),reply.code,reply.reason);
967
+      // 	dlg->reply(*(transfer_req.get()),reply.code,reply.reason);
968 968
       // 	transfer_req.reset(0);
969 969
       // 	setStopped();
970 970
       // }
... ...
@@ -103,11 +103,11 @@ void DSMCall::onInvite(const AmSipRequest& req) {
103 103
   avar[DSM_AVAR_REQUEST] = AmArg(&req);
104 104
 
105 105
   DBG("before runEvent(this, this, DSMCondition::Invite);\n");
106
-  AmSipDialog::Status old_st = dlg.getStatus();
106
+  AmSipDialog::Status old_st = dlg->getStatus();
107 107
   engine.runEvent(this, this, DSMCondition::Invite, NULL);
108 108
   avar.erase(DSM_AVAR_REQUEST);
109 109
 
110
-  if ( old_st != dlg.getStatus()
110
+  if ( old_st != dlg->getStatus()
111 111
        //checkVar(DSM_CONNECT_SESSION, DSM_CONNECT_SESSION_FALSE)
112 112
       ) {
113 113
     DBG("session choose to not connect media\n");
... ...
@@ -277,7 +277,7 @@ void DSMCall::onBye(const AmSipRequest& req)
277 277
 
278 278
 void DSMCall::onCancel(const AmSipRequest& cancel) {
279 279
   DBG("onCancel\n");
280
-  if (dlg.getStatus() < AmSipDialog::Connected) {
280
+  if (dlg->getStatus() < AmSipDialog::Connected) {
281 281
     //TODO: pass the cancel request as a parameter?
282 282
     DBG("hangup event!!!\n");
283 283
     map<string, string> params;
... ...
@@ -331,7 +331,7 @@ void DSMCall::onSipReply(const AmSipRequest& req,
331 331
     params["hdrs"] = reply.hdrs;
332 332
     params["cseq"] = int2str(reply.cseq);
333 333
 
334
-    params["dlg_status"] = dlg.getStatusStr();
334
+    params["dlg_status"] = dlg->getStatusStr();
335 335
     params["old_dlg_status"] = AmBasicSipDialog::getStatusStr(old_dlg_status);
336 336
 
337 337
     // pass AmSipReply for use by mod_dlg (? sending ACK?)
... ...
@@ -353,7 +353,7 @@ void DSMCall::onSipReply(const AmSipRequest& req,
353 353
   AmB2BCallerSession::onSipReply(req, reply, old_dlg_status);
354 354
 
355 355
   if ((old_dlg_status < AmSipDialog::Connected) && 
356
-      (dlg.getStatus() == AmSipDialog::Disconnected)) {
356
+      (dlg->getStatus() == AmSipDialog::Disconnected)) {
357 357
     DBG("Outbound call failed with reply %d %s.\n", 
358 358
 	reply.code, reply.reason.c_str());
359 359
     map<string, string> params;
... ...
@@ -371,7 +371,7 @@ void DSMCall::onRemoteDisappeared(const AmSipReply& reply) {
371 371
   params["hdrs"] = reply.hdrs;
372 372
   params["cseq"] = int2str(reply.cseq);
373 373
 
374
-  params["dlg_status"] = dlg.getStatusStr();
374
+  params["dlg_status"] = dlg->getStatusStr();
375 375
 
376 376
   // pass AmSipReply for use by modules
377 377
   DSMSipReply* dsm_reply = new DSMSipReply(&reply);
... ...
@@ -458,7 +458,7 @@ EXEC_ACTION_START(SCThrowOnErrorAction) {
458 458
 EXEC_ACTION_START(SCStopAction) {
459 459
   if (resolveVars(arg, sess, sc_sess, event_params) == "true") {
460 460
     DBG("sending bye\n");
461
-    sess->dlg.bye();
461
+    sess->dlg->bye();
462 462
   }
463 463
   sess->setStopped();
464 464
 } EXEC_ACTION_END;
... ...
@@ -118,17 +118,17 @@ string resolveVars(const string ts, AmSession* sess,
118 118
       if (s1 == "local_tag")
119 119
 	return sess->getLocalTag();	
120 120
       else if (s1 == "user")
121
-	return sess->dlg.user;
121
+	return sess->dlg->user;
122 122
       else if (s1 == "domain")
123
-	return sess->dlg.domain;
123
+	return sess->dlg->domain;
124 124
       else if (s1 == "remote_tag")
125 125
 	return sess->getRemoteTag();
126 126
       else if (s1 == "callid")
127 127
 	return sess->getCallID();
128 128
       else if (s1 == "local_uri")
129
-	return sess->dlg.local_uri;
129
+	return sess->dlg->local_uri;
130 130
       else if (s1 == "remote_uri")
131
-	return sess->dlg.remote_uri;
131
+	return sess->dlg->remote_uri;
132 132
       else
133 133
 	return string();
134 134
     } 
... ...
@@ -106,7 +106,7 @@ void replyRequest(DSMSession* sc_sess, AmSession* sess,
106 106
 
107 107
   DBG("replying with %i %s, hdrs='%s'\n", code_i, reason.c_str(), hdrs.c_str());
108 108
 
109
-  if (sess->dlg.reply(req, code_i, reason, NULL, hdrs)) {
109
+  if (sess->dlg->reply(req, code_i, reason, NULL, hdrs)) {
110 110
     sc_sess->SET_ERRNO(DSM_ERRNO_GENERAL);
111 111
     sc_sess->SET_STRERROR("error sending reply");
112 112
   } else
... ...
@@ -171,7 +171,7 @@ EXEC_ACTION_START(DLGAcceptInviteAction) {
171 171
 
172 172
   try {
173 173
     AmMimeBody sdp_body;
174
-    if(sess->dlg.reply(*sc_sess->last_req.get(),code_i, reason,
174
+    if(sess->dlg->reply(*sc_sess->last_req.get(),code_i, reason,
175 175
 		       sdp_body.addPart(SIP_APPLICATION_SDP), hdrs) != 0)
176 176
       throw AmSession::Exception(500,"could not send response");
177 177
 
... ...
@@ -179,7 +179,7 @@ EXEC_ACTION_START(DLGAcceptInviteAction) {
179 179
 
180 180
     ERROR("%i %s\n",e.code,e.reason.c_str());
181 181
     sess->setStopped();
182
-    sess->dlg.reply(*sc_sess->last_req.get(),e.code,e.reason);
182
+    sess->dlg->reply(*sc_sess->last_req.get(),e.code,e.reason);
183 183
 
184 184
     sc_sess->SET_ERRNO(DSM_ERRNO_DLG);
185 185
     sc_sess->SET_STRERROR("Error accepting call: "+ int2str(e.code) + " "+ e.reason);
... ...
@@ -189,7 +189,7 @@ EXEC_ACTION_START(DLGAcceptInviteAction) {
189 189
 EXEC_ACTION_START(DLGByeAction) {
190 190
   string hdrs = resolveVars(arg, sess, sc_sess, event_params);
191 191
 
192
-  if (sess->dlg.bye(hdrs)) {
192
+  if (sess->dlg->bye(hdrs)) {
193 193
     sc_sess->SET_ERRNO(DSM_ERRNO_GENERAL);
194 194
     sc_sess->SET_STRERROR("Error sending bye");
195 195
   } else {
... ...
@@ -95,17 +95,17 @@ extern "C" {
95 95
     if (!strcmp("local_tag", varname))
96 96
       res = sc_sess->getLocalTag();	
97 97
     else if (!strcmp("user", varname))
98
-      res = sc_sess->dlg.user;
98
+      res = sc_sess->dlg->user;
99 99
     else if (!strcmp("domain", varname))
100
-      res = sc_sess->dlg.domain;
100
+      res = sc_sess->dlg->domain;
101 101
     else if (!strcmp("remote_tag", varname))
102 102
       res = sc_sess->getRemoteTag();
103 103
     else if (!strcmp("callid", varname))
104 104
       res = sc_sess->getCallID();
105 105
     else if (!strcmp("local_uri", varname))
106
-      res = sc_sess->dlg.local_uri;
106
+      res = sc_sess->dlg->local_uri;
107 107
     else if (!strcmp("remote_uri", varname))
108
-      res = sc_sess->dlg.remote_uri;
108
+      res = sc_sess->dlg->remote_uri;
109 109
 
110 110
     DBG("returning '%s'\n", res.c_str());
111 111
 
... ...
@@ -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 {
... ...
@@ -159,7 +159,7 @@ void AnnounceAuthDialog::process(AmEvent* event)
159 159
 
160 160
   AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event);
161 161
   if(audio_event && (audio_event->event_id == AmAudioEvent::cleared)){
162
-    dlg.bye();
162
+    dlg->bye();
163 163
     setStopped();
164 164
     return;
165 165
   }
... ...
@@ -85,7 +85,7 @@ b2b_connectDialog::~b2b_connectDialog()
85 85
 
86 86
 void b2b_connectDialog::onInvite(const AmSipRequest& req)
87 87
 {
88
-  if (dlg.getStatus() == AmSipDialog::Connected) {
88
+  if (dlg->getStatus() == AmSipDialog::Connected) {
89 89
     // reinvites
90 90
     AmB2ABCallerSession::onInvite(req);
91 91
     return;
... ...
@@ -109,7 +109,7 @@ void b2b_connectDialog::onInvite(const AmSipRequest& req)
109 109
       remote_uri = to = "sip:"+req.user+"@"+domain;
110 110
       remote_party = "<" + to + ">";
111 111
   }
112
-  if(dlg.reply(req, 100, "Connecting") != 0) {
112
+  if(dlg->reply(req, 100, "Connecting") != 0) {
113 113
     throw AmSession::Exception(500,"Failed to reply 100");
114 114
   }
115 115
 
... ...
@@ -141,10 +141,10 @@ void b2b_connectDialog::onB2ABEvent(B2ABEvent* ev)
141 141
   if (ev->event_id == B2ABConnectOtherLegException) {
142 142
     B2ABConnectOtherLegExceptionEvent* ex_ev = 
143 143
       dynamic_cast<B2ABConnectOtherLegExceptionEvent*>(ev);
144
-    if (ex_ev && dlg.getStatus() < AmSipDialog::Connected) {
144
+    if (ex_ev && dlg->getStatus() < AmSipDialog::Connected) {
145 145
       DBG("callee leg creation failed with exception '%d %s'\n",
146 146
 	  ex_ev->code, ex_ev->reason.c_str());
147
-      dlg.reply(invite_req, ex_ev->code, ex_ev->reason);
147
+      dlg->reply(invite_req, ex_ev->code, ex_ev->reason);
148 148
       setStopped();
149 149
       return;
150 150
     }
... ...
@@ -153,10 +153,10 @@ void b2b_connectDialog::onB2ABEvent(B2ABEvent* ev)
153 153
   if (ev->event_id == B2ABConnectOtherLegFailed) {
154 154
     B2ABConnectOtherLegFailedEvent* f_ev = 
155 155
       dynamic_cast<B2ABConnectOtherLegFailedEvent*>(ev);
156
-    if (f_ev && dlg.getStatus() < AmSipDialog::Connected) {
156
+    if (f_ev && dlg->getStatus() < AmSipDialog::Connected) {
157 157
       DBG("callee leg creation failed with reply '%d %s'\n",
158 158
 	  f_ev->code, f_ev->reason.c_str());
159
-      dlg.reply(invite_req, f_ev->code, f_ev->reason);
159
+      dlg->reply(invite_req, f_ev->code, f_ev->reason);
160 160
       setStopped();
161 161
       return;
162 162
     }
... ...
@@ -212,12 +212,12 @@ void b2b_connectDialog::onBye(const AmSipRequest& req)
212 212
 
213 213
 void b2b_connectDialog::onCancel(const AmSipRequest& req)
214 214
 {
215
-  if(dlg.getStatus() < AmSipDialog::Connected) {
215
+  if(dlg->getStatus() < AmSipDialog::Connected) {
216 216
     DBG("Wait for leg B to terminate");
217 217
   }
218 218
   else {
219 219
     DBG("Canceling leg A on CANCEL since dialog is not pending");
220
-    dlg.reply(invite_req, 487, "Request terminated");
220
+    dlg->reply(invite_req, 487, "Request terminated");
221 221
     setStopped();
222 222
   }
223 223
 }
... ...
@@ -257,7 +257,7 @@ void b2b_connectCalleeSession::onSipReply(const AmSipReply& reply,
257 257
   AmB2ABCalleeSession::onSipReply(reply, old_dlg_status);
258 258
  
259 259
   if ((old_dlg_status < AmSipDialog::Connected) &&
260
-      (dlg.getStatus() == AmSipDialog::Disconnected)) {
260
+      (dlg->getStatus() == AmSipDialog::Disconnected)) {
261 261
     DBG("status change Pending -> Disconnected. Stopping session.\n");
262 262
     setStopped();
263 263
   }
... ...
@@ -465,7 +465,7 @@ void CallGenDialog::process(AmEvent* event)
465 465
     play_list.flush();
466 466
     setInOut(NULL,NULL);
467 467
     setStopped();
468
-    dlg.bye();
468
+    dlg->bye();
469 469
   }
470 470
   else
471 471
     AmSession::process(event);
... ...
@@ -484,7 +484,7 @@ void CallGenDialog::onBye(const AmSipRequest& req) {
484 484
 void CallGenDialog::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status) {
485 485
   AmSession::onSipReply(reply, old_dlg_status);
486 486
   if ((old_dlg_status < AmSipDialog::Connected) &&
487
-      dlg.getStatus() == AmSipDialog::Disconnected) {
487
+      dlg->getStatus() == AmSipDialog::Disconnected) {
488 488
     DBG("SIP dialog status change: < Connected -> Disconnected, stopping call\n");
489 489
     setStopped();
490 490
   }
... ...
@@ -160,7 +160,7 @@ void DtmfTesterDialog::process(AmEvent* event)
160 160
 
161 161
   AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event);
162 162
   if(audio_event && (audio_event->event_id == AmAudioEvent::cleared)){
163
-    dlg.bye();
163
+    dlg->bye();
164 164
     setStopped();
165 165
     return;
166 166
   }
... ...
@@ -99,7 +99,7 @@ void EarlyRecordDialog::process(AmEvent* event)
99 99
 
100 100
   AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event);
101 101
   if(audio_event && (audio_event->event_id == AmAudioEvent::cleared)){
102
-    dlg.bye();
102
+    dlg->bye();
103 103
     setStopped();
104 104
     return;
105 105
   }
... ...
@@ -84,7 +84,7 @@ void JukecallSession::onSessionStart()
84 84
   DBG("playing file\n");
85 85
 
86 86
   if(initial_announcement.open(INITIAL_ANNOUNCEMENT,AmAudioFile::Read)) {
87
-    dlg.bye();
87
+    dlg->bye();
88 88
     throw string("CTConfDDialog::onSessionStart: Cannot open file '%s'\n", INITIAL_ANNOUNCEMENT);
89 89
   }
90 90
 
... ...
@@ -128,10 +128,10 @@ void JukecallSession::process(AmEvent* event)
128 128
     switch(state) {
129 129
     case JC_initial_announcement: {
130 130
       state = JC_connect;
131
-      string callee = "sip:" + dlg.user.substr(3) + "@" + dlg.domain;
131
+      string callee = "sip:" + dlg->user.substr(3) + "@" + dlg->domain;
132 132
       DBG("-------------------------- connecting %s ------------------------\n", callee.c_str());
133 133
       connectCallee(callee, callee, 
134
-		    dlg.remote_party, dlg.remote_uri);
134
+		    dlg->remote_party, dlg->remote_uri);
135 135
 
136 136
       return;
137 137
 
... ...
@@ -72,7 +72,7 @@ SimpleConferenceDialog::~SimpleConferenceDialog()
72 72
 void SimpleConferenceDialog::onSessionStart()
73 73
 {
74 74
   // set the conference id ('conference room') to user part of ruri
75
-  conf_id = dlg.user;
75
+  conf_id = dlg->user;
76 76
 
77 77
   // open the beep file
78 78
   BeepSound.reset(new AmAudioFile());
... ...
@@ -502,16 +502,16 @@ void IvrFactory::start_deferred_threads() {
502 502
 
503 503
 int IvrDialog::transfer(const string& target)
504 504
 {
505
-  return dlg.transfer(target);
505
+  return dlg->transfer(target);
506 506
 }
507 507
 
508 508
 int IvrDialog::refer(const string& target, int expires) {
509
-  return dlg.refer(target, expires);
509
+  return dlg->refer(target, expires);
510 510
 }
511 511
 
512 512
 int IvrDialog::drop()
513 513
 {
514
-  int res = dlg.drop();
514
+  int res = dlg->drop();
515 515
   if (res) 
516 516
     setStopped();
517 517
 	
... ...
@@ -795,29 +795,29 @@ void IvrDialog::connectCallee(const string& remote_party, const string& remote_u
795 795
 void IvrDialog::createCalleeSession()
796 796
 {
797 797
   AmB2BCalleeSession* callee_session = new AmB2BCalleeSession(this);
798
-  AmSipDialog& callee_dlg = callee_session->dlg;
798
+  AmSipDialog* callee_dlg = callee_session->dlg;
799 799
   
800 800
   other_id = AmSession::getNewId();
801 801
   
802
-  callee_dlg.local_tag    = other_id;
803
-  callee_dlg.callid       = AmSession::getNewId();
802
+  callee_dlg->local_tag    = other_id;
803
+  callee_dlg->callid       = AmSession::getNewId();
804 804
   
805 805
   // this will be overwritten by ConnectLeg event 
806
-  callee_dlg.remote_party = dlg.local_party;
807
-  callee_dlg.remote_uri   = dlg.local_uri;
806
+  callee_dlg->remote_party = dlg->local_party;
807
+  callee_dlg->remote_uri   = dlg->local_uri;
808 808
 
809 809
   if (b2b_callee_from_party.empty() && b2b_callee_from_uri.empty()) {
810 810
     // default: use the original To as From in the callee leg
811
-    callee_dlg.local_party  = dlg.remote_party;
812
-    callee_dlg.local_uri  = dlg.remote_uri;
811
+    callee_dlg->local_party  = dlg->remote_party;
812
+    callee_dlg->local_uri  = dlg->remote_uri;
813 813
   } else {
814 814
     // if given as parameters, use these
815
-    callee_dlg.local_party  = b2b_callee_from_party;
816
-    callee_dlg.local_uri  = b2b_callee_from_uri;
815
+    callee_dlg->local_party  = b2b_callee_from_party;
816
+    callee_dlg->local_uri  = b2b_callee_from_uri;
817 817
   }
818 818
   
819 819
   DBG("Created B2BUA callee leg, From: %s\n",
820
-      callee_dlg.local_party.c_str());
820
+      callee_dlg->local_party.c_str());
821 821
 
822 822
   callee_session->start();
823 823
   
... ...
@@ -45,7 +45,7 @@ static PyObject* IvrDialogBase_new(PyTypeObject *type, PyObject *args, PyObject
45 45
     self->p_dlg = (IvrDialog*)PyCObject_AsVoidPtr(o_dlg);
46 46
 	
47 47
     // initialize self.dialog
48
-    self->dialog = IvrSipDialog_FromPtr(&self->p_dlg->dlg);
48
+    self->dialog = IvrSipDialog_FromPtr(self->p_dlg->dlg);
49 49
     if(!self->dialog){
50 50
       PyErr_Print();
51 51
       ERROR("IvrDialogBase: while creating IvrSipDialog instance\n");
... ...
@@ -124,7 +124,7 @@ static PyObject* IvrDialogBase_bye(IvrDialogBase* self, PyObject* args)
124 124
   if(!PyArg_ParseTuple(args,"|s", &hdrs))
125 125
     return NULL;
126 126
 
127
-  self->p_dlg->dlg.bye(hdrs);
127
+  self->p_dlg->dlg->bye(hdrs);
128 128
   Py_INCREF(Py_None);
129 129
   return Py_None;
130 130
 }
... ...
@@ -78,7 +78,7 @@ void PrecodedDialog::onSessionStart()
78 78
   }
79 79
   if (!file || file->open()) { 
80 80
     ERROR("PrecodedDialog::onSessionStart: Cannot open file\n");
81
-    dlg.bye();
81
+    dlg->bye();
82 82
     setStopped();
83 83
     return;
84 84
   }
... ...
@@ -670,30 +670,30 @@ void RtmpConnection::rxAudio(RTMPPacket *packet)
670 670
 RtmpSession* RtmpConnection::startSession(const char* uri)
671 671
 {
672 672
   auto_ptr<RtmpSession> n_session(new RtmpSession(this));
673
-  AmSipDialog& dialout_dlg = n_session->dlg;
673
+  AmSipDialog* dialout_dlg = n_session->dlg;
674 674
 
675 675
   string dialout_id = AmSession::getNewId();
676
-  dialout_dlg.local_tag    = dialout_id;
677
-  dialout_dlg.callid       = AmSession::getNewId();
676
+  dialout_dlg->local_tag    = dialout_id;
677
+  dialout_dlg->callid       = AmSession::getNewId();
678 678
 
679
-  dialout_dlg.remote_party = "<" + string(uri) + ">";
680
-  dialout_dlg.remote_uri   = uri;
679
+  dialout_dlg->remote_party = "<" + string(uri) + ">";
680
+  dialout_dlg->remote_uri   = uri;
681 681
 
682
-  dialout_dlg.local_party  = "\"" + rtmp_cfg->FromName + "\" "
682
+  dialout_dlg->local_party  = "\"" + rtmp_cfg->FromName + "\" "
683 683
     "<sip:" + ident + "@";
684 684
 
685 685
   if(!rtmp_cfg->FromDomain.empty()){
686
-    dialout_dlg.local_party += rtmp_cfg->FromDomain;
686
+    dialout_dlg->local_party += rtmp_cfg->FromDomain;
687 687
   }
688 688
   else {
689
-    int out_if = dialout_dlg.getOutboundIf();
690
-    dialout_dlg.local_party += AmConfig::SIP_Ifs[out_if].LocalIP;
689
+    int out_if = dialout_dlg->getOutboundIf();
690
+    dialout_dlg->local_party += AmConfig::SIP_Ifs[out_if].LocalIP;
691 691
     if(AmConfig::SIP_Ifs[out_if].LocalPort != 5060)
692
-      dialout_dlg.local_party += 
692
+      dialout_dlg->local_party += 
693 693
 	":" + int2str(AmConfig::SIP_Ifs[out_if].LocalPort);
694 694
   }
695 695
 
696
-  dialout_dlg.local_party += ">";
696
+  dialout_dlg->local_party += ">";
697 697
   
698 698
   n_session->setCallgroup(dialout_id);
699 699
   switch(AmSessionContainer::instance()->addSession(dialout_id,
... ...
@@ -714,8 +714,8 @@ RtmpSession* RtmpConnection::startSession(const char* uri)
714 714
   sdp_body.addPart(SIP_APPLICATION_SDP);
715 715
 
716 716
   RtmpSession* pn_session = n_session.release();
717
-  if(dialout_dlg.sendRequest(SIP_METH_INVITE,&sdp_body) < 0) {
718
-    ERROR("dialout_dlg.sendRequest() returned an error\n");
717
+  if(dialout_dlg->sendRequest(SIP_METH_INVITE,&sdp_body) < 0) {
718
+    ERROR("dialout_dlg->sendRequest() returned an error\n");
719 719
     AmSessionContainer::instance()->destroySession(pn_session);
720 720
     return NULL;
721 721
   }
... ...
@@ -56,8 +56,8 @@ void RtmpSession::sendCallState()
56 56
 {
57 57
   m_rtmp_conn.lock();
58 58
   if(rtmp_connection){
59
-    DBG("Dialog status: %s\n",dlg.getStatusStr());
60
-    unsigned int rtmp_call_status = __dlg_status2rtmp_call[dlg.getStatus()];
59
+    DBG("Dialog status: %s\n",dlg->getStatusStr());
60
+    unsigned int rtmp_call_status = __dlg_status2rtmp_call[dlg->getStatus()];
61 61
     rtmp_connection->SendCallStatus(rtmp_call_status);
62 62
   }
63 63
   m_rtmp_conn.unlock();
... ...
@@ -117,16 +117,16 @@ void RtmpSession::onSipReply(const AmSipRequest& req,
117 117
 
118 118
   sendCallState();
119 119
 
120
-  if(dlg.getStatus() == AmSipDialog::Disconnected) {
120
+  if(dlg->getStatus() == AmSipDialog::Disconnected) {
121 121
     setStopped();
122 122
   }
123 123
 }
124 124
 
125 125
 void RtmpSession::onInvite(const AmSipRequest& req)
126 126
 {
127
-  DBG("status str: %s\n",dlg.getStatusStr());
127
+  DBG("status str: %s\n",dlg->getStatusStr());
128 128
 
129
-  if(dlg.getStatus() != AmSipDialog::Trying){
129
+  if(dlg->getStatus() != AmSipDialog::Trying){
130 130
     AmSession::onInvite(req);
131 131
     return;
132 132
   }
... ...
@@ -136,7 +136,7 @@ void RtmpSession::onInvite(const AmSipRequest& req)
136 136
   rtmp_connection->NotifyIncomingCall(req.user);
137 137
   m_rtmp_conn.unlock();
138 138
 
139
-  dlg.reply(req,180,"Ringing");
139
+  dlg->reply(req,180,"Ringing");
140 140
 }
141 141
 
142 142
 void RtmpSession::process(AmEvent* ev)
... ...
@@ -145,17 +145,17 @@ void RtmpSession::process(AmEvent* ev)
145 145
   if(rtmp_ev){
146 146
     switch(rtmp_ev->getEvType()){
147 147
     case RtmpSessionEvent::Disconnect:
148
-      dlg.bye();
148
+      dlg->bye();
149 149
       setStopped();
150 150
       return;
151 151
     case RtmpSessionEvent::Accept:
152
-      AmSipRequest* inv_req = dlg.getUASPendingInv();
152
+      AmSipRequest* inv_req = dlg->getUASPendingInv();
153 153
       if(!inv_req){
154 154
 	//Error: no pending INVITE
155 155
 	sendCallState();
156 156
 	return;
157 157
       }
158
-      dlg.reply(*inv_req,200,"OK");
158
+      dlg->reply(*inv_req,200,"OK");
159 159
       sendCallState();
160 160
       return;
161 161
     }
... ...
@@ -60,15 +60,15 @@ CallLeg::CallLeg(const CallLeg* caller):
60 60
 
61 61
   // code below taken from createCalleeSession
62 62
 
63
-  const AmSipDialog& caller_dlg = caller->dlg;
63
+  const AmSipDialog* caller_dlg = caller->dlg;
64 64
 
65
-  dlg.local_tag    = AmSession::getNewId();
66
-  dlg.callid       = AmSession::getNewId();
65
+  dlg->local_tag    = AmSession::getNewId();
66
+  dlg->callid       = AmSession::getNewId();
67 67
 
68 68
   // take important data from A leg
69
-  dlg.local_party  = caller_dlg.remote_party;
70
-  dlg.remote_party = caller_dlg.local_party;
71
-  dlg.remote_uri   = caller_dlg.local_uri;
69
+  dlg->local_party  = caller_dlg->remote_party;
70
+  dlg->remote_party = caller_dlg->local_party;
71
+  dlg->remote_uri   = caller_dlg->local_uri;
72 72
 
73 73
 /*  if (AmConfig::LogSessions) {
74 74
     INFO("Starting B2B callee session %s\n",
... ...
@@ -77,9 +77,9 @@ CallLeg::CallLeg(const CallLeg* caller):
77 77
 
78 78
   MONITORING_LOG4(other_id.c_str(), 
79 79
 		  "dir",  "out",
80
-		  "from", dlg.local_party.c_str(),
81
-		  "to",   dlg.remote_party.c_str(),
82
-		  "ruri", dlg.remote_uri.c_str());
80
+		  "from", dlg->local_party.c_str(),
81
+		  "to",   dlg->remote_party.c_str(),
82
+		  "ruri", dlg->remote_uri.c_str());
83 83
 */
84 84
 
85 85
   // copy common RTP relay settings from A leg
... ...
@@ -343,7 +343,7 @@ void CallLeg::onB2BReply(B2BSipReplyEvent *ev)
343 343
       other_legs.begin()->releaseMediaSession(); // remove reference hold by OtherLegInfo
344 344
       other_legs.clear(); // no need to remember the connected leg here
345 345
       if (media_session) {
346
-        TRACE("connecting media session: %s to %s\n", dlg.local_tag.c_str(), other_id.c_str());
346
+        TRACE("connecting media session: %s to %s\n", dlg->local_tag.c_str(), other_id.c_str());
347 347
         media_session->changeSession(a_leg, this);
348 348
         if (initial_sdp_stored && ev->forward) updateRemoteSdp(initial_sdp);
349 349
       }
... ...
@@ -413,8 +413,8 @@ void CallLeg::onB2BConnect(ConnectLegEvent* co_ev)
413 413
 
414 414
   MONITORING_LOG3(getLocalTag().c_str(), 
415 415
       "b2b_leg", other_id.c_str(),
416
-      "to", dlg.remote_party.c_str(),
417
-      "ruri", dlg.remote_uri.c_str());
416
+      "to", dlg->remote_party.c_str(),
417
+      "ruri", dlg->remote_uri.c_str());
418 418
 
419 419
   // This leg is marked as 'relay only' since the beginning because it might
420 420
   // need not to know on time that it is connected and thus should relay.
... ...
@@ -444,7 +444,7 @@ void CallLeg::onB2BConnect(ConnectLegEvent* co_ev)
444 444
     }
445 445
   }
446 446
 
447
-  int res = dlg.sendRequest(SIP_METH_INVITE, body,
447
+  int res = dlg->sendRequest(SIP_METH_INVITE, body,
448 448
       co_ev->hdrs, SIP_FLAGS_VERBATIM);
449 449
   if (res < 0) {
450 450
     DBG("sending INVITE failed, relaying back error reply\n");
... ...
@@ -458,7 +458,7 @@ void CallLeg::onB2BConnect(ConnectLegEvent* co_ev)
458 458
     AmSipRequest fake_req;
459 459
     fake_req.method = SIP_METH_INVITE;
460 460
     fake_req.cseq = co_ev->r_cseq;
461
-    relayed_req[dlg.cseq - 1] = fake_req;
461
+    relayed_req[dlg->cseq - 1] = fake_req;
462 462
     est_invite_other_cseq = co_ev->r_cseq;
463 463
   }
464 464
   else est_invite_other_cseq = 0;
... ...
@@ -468,7 +468,7 @@ void CallLeg::onB2BConnect(ConnectLegEvent* co_ev)
468 468
   }
469 469
 
470 470
   // save CSeq of establising INVITE
471
-  est_invite_cseq = dlg.cseq - 1;
471
+  est_invite_cseq = dlg->cseq - 1;
472 472
 }
473 473
 
474 474
 void CallLeg::onB2BReconnect(ReconnectLegEvent* ev)
... ...
@@ -506,8 +506,8 @@ void CallLeg::onB2BReconnect(ReconnectLegEvent* ev)
506 506
 
507 507
   MONITORING_LOG3(getLocalTag().c_str(),
508 508
       "b2b_leg", other_id.c_str(),
509
-      "to", dlg.remote_party.c_str(),
510
-      "ruri", dlg.remote_uri.c_str());
509
+      "to", dlg->remote_party.c_str(),
510
+      "ruri", dlg->remote_uri.c_str());
511 511
 
512 512
   AmMimeBody r_body(ev->body);
513 513
   const AmMimeBody* body = &ev->body;
... ...
@@ -527,7 +527,7 @@ void CallLeg::onB2BReconnect(ReconnectLegEvent* ev)
527 527
   }
528 528
 
529 529
   // generate re-INVITE
530
-  int res = dlg.sendRequest(SIP_METH_INVITE, body, ev->hdrs, SIP_FLAGS_VERBATIM);
530
+  int res = dlg->sendRequest(SIP_METH_INVITE, body, ev->hdrs, SIP_FLAGS_VERBATIM);
531 531
   if (res < 0) {
532 532
     DBG("sending re-INVITE failed, relaying back error reply\n");
533 533
     relayError(SIP_METH_INVITE, ev->r_cseq, true, res);
... ...
@@ -540,7 +540,7 @@ void CallLeg::onB2BReconnect(ReconnectLegEvent* ev)
540 540
     AmSipRequest fake_req;
541 541
     fake_req.method = SIP_METH_INVITE;
542 542
     fake_req.cseq = ev->r_cseq;
543
-    relayed_req[dlg.cseq - 1] = fake_req;
543
+    relayed_req[dlg->cseq - 1] = fake_req;
544 544
     est_invite_other_cseq = ev->r_cseq;
545 545
   }
546 546
   else est_invite_other_cseq = 0;
... ...
@@ -548,7 +548,7 @@ void CallLeg::onB2BReconnect(ReconnectLegEvent* ev)
548 548
   saveSessionDescription(ev->body);
549 549
 
550 550
   // save CSeq of establising INVITE
551
-  est_invite_cseq = dlg.cseq - 1;
551
+  est_invite_cseq = dlg->cseq - 1;
552 552
 }
553 553
 
554 554
 void CallLeg::onB2BReplace(ReplaceLegEvent *e)
... ...
@@ -685,11 +685,11 @@ void CallLeg::putOnHold()
685 685
   string body_str;
686 686
   sdp.print(body_str);
687 687
   body.parse(SIP_APPLICATION_SDP, (const unsigned char*)body_str.c_str(), body_str.length());
688
-  if (dlg.reinvite("", &body, SIP_FLAGS_VERBATIM) != 0) {
688
+  if (dlg->reinvite("", &body, SIP_FLAGS_VERBATIM) != 0) {
689 689
     ERROR("re-INVITE failed\n");
690 690
     handleHoldReply(false);
691 691
   }
692
-  else hold_request_cseq = dlg.cseq - 1;
692
+  else hold_request_cseq = dlg->cseq - 1;
693 693
 }
694 694
 
695 695
 void CallLeg::resumeHeld(bool send_reinvite)
... ...
@@ -716,11 +716,11 @@ void CallLeg::resumeHeld(bool send_reinvite)
716 716
       updateLocalSdp(sdp);
717 717
   }
718 718
 
719
-  if (dlg.reinvite("", &established_body, SIP_FLAGS_VERBATIM) != 0) {
719
+  if (dlg->reinvite("", &established_body, SIP_FLAGS_VERBATIM) != 0) {
720 720
     ERROR("re-INVITE failed\n");
721 721
     handleHoldReply(false);
722 722
   }
723
-  else hold_request_cseq = dlg.cseq - 1;
723
+  else hold_request_cseq = dlg->cseq - 1;
724 724
 }
725 725
 
726 726
 void CallLeg::handleHoldReply(bool succeeded)
... ...
@@ -927,12 +927,12 @@ void CallLeg::addNewCallee(CallLeg *callee, ConnectLegEvent *e, AmB2BSession::RT
927 927
 	 callee->getLocalTag().c_str()/*, invite_req.cmd.c_str()*/);
928 928
   }
929 929
 
930
-  AmSipDialog& callee_dlg = callee->dlg;
930
+  AmSipDialog* callee_dlg = callee->dlg;
931 931
   MONITORING_LOG4(b.id.c_str(),
932 932
 		  "dir",  "out",
933
-		  "from", callee_dlg.local_party.c_str(),
934
-		  "to",   callee_dlg.remote_party.c_str(),
935
-		  "ruri", callee_dlg.remote_uri.c_str());
933
+		  "from", callee_dlg->local_party.c_str(),
934
+		  "to",   callee_dlg->remote_party.c_str(),
935
+		  "ruri", callee_dlg->remote_uri.c_str());
936 936
 
937 937
   callee->start();
938 938
 
... ...
@@ -146,11 +146,11 @@ SBCCallLeg::SBCCallLeg(const SBCCallProfile& call_profile)
146 146
     cc_timer_id(SBC_TIMER_ID_CALL_TIMERS_START)
147 147
 {
148 148
   set_sip_relay_only(false);
149
-  dlg.setRel100State(Am100rel::REL100_IGNORED);
149
+  dlg->setRel100State(Am100rel::REL100_IGNORED);
150 150
 
151 151
   // better here than in onInvite
152 152
   // or do we really want to start with OA when handling initial INVITE?
153
-  dlg.setOAEnabled(false);
153
+  dlg->setOAEnabled(false);
154 154
 
155 155
   memset(&call_connect_ts, 0, sizeof(struct timeval));
156 156
   memset(&call_end_ts, 0, sizeof(struct timeval));
... ...
@@ -168,15 +168,15 @@ SBCCallLeg::SBCCallLeg(SBCCallLeg* caller)
168 168
   // something, so just take care when using stored objects...
169 169
   // call_profile.cc_vars.clear();
170 170
 
171
-  dlg.setRel100State(Am100rel::REL100_IGNORED);
172
-  dlg.setOAEnabled(false);
171
+  dlg->setRel100State(Am100rel::REL100_IGNORED);
172
+  dlg->setOAEnabled(false);
173 173
 
174 174
   // we need to apply it here instead of in applyBProfile because we have caller
175 175
   // here (FIXME: do it on better place and better way than accessing internals
176 176
   // of caller->dlg directly)
177 177
   if (call_profile.transparent_dlg_id && caller) {
178
-    dlg.callid = caller->dlg.callid;
179
-    dlg.ext_local_tag = caller->dlg.remote_tag;
178
+    dlg->callid = caller->dlg->callid;
179
+    dlg->ext_local_tag = caller->dlg->remote_tag;
180 180
   }
181 181
 
182 182
   // CC interfaces and variables should be already "evaluated" by A leg, we just
... ...
@@ -275,7 +275,7 @@ void SBCCallLeg::applyBProfile()
275 275
 {
276 276
   // TODO: fix this!!! (see d85ed5c7e6b8d4c24e7e5b61c732c2e1ddd31784)
277 277
   // if (!call_profile.contact.empty()) {
278
-  //   dlg.contact_uri = SIP_HDR_COLSP(SIP_HDR_CONTACT) + call_profile.contact + CRLF;
278
+  //   dlg->contact_uri = SIP_HDR_COLSP(SIP_HDR_CONTACT) + call_profile.contact + CRLF;
279 279
   // }
280 280
 
281 281
   if (call_profile.auth_enabled) {
... ...
@@ -301,18 +301,18 @@ void SBCCallLeg::applyBProfile()
301 301
   }
302 302
 
303 303
   if (!call_profile.outbound_proxy.empty()) {
304
-    dlg.outbound_proxy = call_profile.outbound_proxy;
305
-    dlg.force_outbound_proxy = call_profile.force_outbound_proxy;
304
+    dlg->outbound_proxy = call_profile.outbound_proxy;
305
+    dlg->force_outbound_proxy = call_profile.force_outbound_proxy;
306 306
   }
307 307
 
308 308
   if (!call_profile.next_hop.empty()) {
309
-    dlg.next_hop = call_profile.next_hop;
310
-    dlg.next_hop_1st_req = call_profile.next_hop_1st_req;
309
+    dlg->next_hop = call_profile.next_hop;
310
+    dlg->next_hop_1st_req = call_profile.next_hop_1st_req;
311 311
   }
312 312
 
313 313
   // was read from caller but reading directly from profile now
314 314
   if (call_profile.outbound_interface_value >= 0)
315
-    dlg.outbound_interface = call_profile.outbound_interface_value;
315
+    dlg->outbound_interface = call_profile.outbound_interface_value;
316 316
 
317 317
   // was read from caller but reading directly from profile now
318 318
   if (call_profile.rtprelay_enabled || call_profile.transcoder.isActive()) {
... ...
@@ -324,7 +324,7 @@ void SBCCallLeg::applyBProfile()
324 324
   setRtpRelayTransparentSSRC(call_profile.rtprelay_transparent_ssrc);
325 325
 
326 326
   // was read from caller but reading directly from profile now
327
-  if (!call_profile.callid.empty()) dlg.callid = call_profile.callid;
327
+  if (!call_profile.callid.empty()) dlg->callid = call_profile.callid;
328 328
 }
329 329
 
330 330
 int SBCCallLeg::relayEvent(AmEvent* ev)
... ...
@@ -356,8 +356,8 @@ int SBCCallLeg::relayEvent(AmEvent* ev)
356 356
           assert(reply_ev);
357 357
 
358 358
           if(call_profile.transparent_dlg_id &&
359
-              (reply_ev->reply.to_tag == dlg.ext_local_tag))
360
-            reply_ev->reply.to_tag = dlg.local_tag;
359
+              (reply_ev->reply.to_tag == dlg->ext_local_tag))
360
+            reply_ev->reply.to_tag = dlg->local_tag;
361 361
 
362 362
           if (call_profile.headerfilter.size() ||
363 363
               call_profile.reply_translations.size()) {
... ...
@@ -429,7 +429,7 @@ void SBCCallLeg::onSipRequest(const AmSipRequest& req) {
429 429
 	  (it->filter_list.find(req.method) != it->filter_list.end());
430 430
 	if (is_filtered) {
431 431
 	  DBG("replying 405 to filtered message '%s'\n", req.method.c_str());
432
-	  dlg.reply(req, 405, "Method Not Allowed", NULL, "", SIP_FLAGS_VERBATIM);
432
+	  dlg->reply(req, 405, "Method Not Allowed", NULL, "", SIP_FLAGS_VERBATIM);
433 433
 	  return;
434 434
 	}
435 435
       }
... ...
@@ -458,9 +458,9 @@ void SBCCallLeg::onSipReply(const AmSipRequest& req, const AmSipReply& reply,
458 458
 
459 459
   if (NULL != auth) {
460 460
     // only for SIP authenticated
461
-    unsigned int cseq_before = dlg.cseq;
461
+    unsigned int cseq_before = dlg->cseq;
462 462
     if (auth->onSipReply(req, reply, old_dlg_status)) {
463
-      if (cseq_before != dlg.cseq) {
463
+      if (cseq_before != dlg->cseq) {
464 464
         DBG("uac_auth consumed reply with cseq %d and resent with cseq %d; "
465 465
             "updating relayed_req map\n", reply.cseq, cseq_before);
466 466
         updateUACTransCSeq(reply.cseq, cseq_before);
... ...
@@ -662,7 +662,7 @@ void SBCCallLeg::onInvite(const AmSipRequest& req)
662 662
     }
663 663
   }
664 664
 
665
-  if(dlg.reply(req, 100, "Connecting") != 0) {
665
+  if(dlg->reply(req, 100, "Connecting") != 0) {
666 666
     throw AmSession::Exception(500,"Failed to reply 100");
667 667
   }
668 668
 
... ...
@@ -847,7 +847,7 @@ void SBCCallLeg::onBye(const AmSipRequest& req)
847 847
 
848 848
 void SBCCallLeg::onCancel(const AmSipRequest& cancel)
849 849
 {
850
-  dlg.bye();
850
+  dlg->bye();
851 851
   stopCall();
852 852
 }
853 853
 
... ...
@@ -927,7 +927,7 @@ bool SBCCallLeg::CCStart(const AmSipRequest& req) {
927 927
 	    "module '%s' named '%s', parameters '%s'\n",
928 928
 	    cc_if.cc_module.c_str(), cc_if.cc_name.c_str(),
929 929
 	    AmArg::print(di_args).c_str());
930
-      dlg.reply(req, 500, SIP_REPLY_SERVER_INTERNAL_ERROR);
930
+      dlg->reply(req, 500, SIP_REPLY_SERVER_INTERNAL_ERROR);
931 931
 
932 932
       // call 'end' of call control modules up to here
933 933
       call_end_ts.tv_sec = call_start_ts.tv_sec;
... ...
@@ -940,7 +940,7 @@ bool SBCCallLeg::CCStart(const AmSipRequest& req) {
940 940
 	    "module '%s' named '%s', parameters '%s'\n",
941 941
 	    cc_if.cc_module.c_str(), cc_if.cc_name.c_str(),
942 942
 	    AmArg::print(di_args).c_str());
943
-      dlg.reply(req, 500, SIP_REPLY_SERVER_INTERNAL_ERROR);
943
+      dlg->reply(req, 500, SIP_REPLY_SERVER_INTERNAL_ERROR);
944 944
 
945 945
       // call 'end' of call control modules up to here
946 946
       call_end_ts.tv_sec = call_start_ts.tv_sec;
... ...
@@ -964,7 +964,7 @@ bool SBCCallLeg::CCStart(const AmSipRequest& req) {
964 964
 	case SBC_CC_DROP_ACTION: {
965 965
 	  DBG("dropping call on call control action DROP from '%s'\n",
966 966
 	      cc_if.cc_name.c_str());
967
-	  dlg.setStatus(AmSipDialog::Disconnected);
967
+	  dlg->setStatus(AmSipDialog::Disconnected);
968 968
 
969 969
 	  // call 'end' of call control modules up to here
970 970
 	  call_end_ts.tv_sec = call_start_ts.tv_sec;
... ...
@@ -992,7 +992,7 @@ bool SBCCallLeg::CCStart(const AmSipRequest& req) {
992 992
 	      ret[i][SBC_CC_REFUSE_CODE].asInt(), ret[i][SBC_CC_REFUSE_REASON].asCStr(),
993 993
 	      cc_if.cc_name.c_str(), headers.c_str());
994 994
 
995
-	  dlg.reply(req,
995
+	  dlg->reply(req,
996 996
 		    ret[i][SBC_CC_REFUSE_CODE].asInt(), ret[i][SBC_CC_REFUSE_REASON].asCStr(),
997 997
 		    NULL, headers);
998 998
 
... ...
@@ -1335,8 +1335,8 @@ bool SBCCallLeg::reinvite(const AmSdp &sdp, unsigned &request_cseq)
1335 1335
   sdp.print(body_str);
1336 1336
   sdp_body->parse(SIP_APPLICATION_SDP, (const unsigned char*)body_str.c_str(), body_str.length());
1337 1337
 
1338
-  if (dlg.reinvite("", &body, SIP_FLAGS_VERBATIM) != 0) return false;
1339
-  request_cseq = dlg.cseq - 1;
1338
+  if (dlg->reinvite("", &body, SIP_FLAGS_VERBATIM) != 0) return false;
1339
+  request_cseq = dlg->cseq - 1;
1340 1340
   return true;
1341 1341
 }
1342 1342
 
... ...
@@ -131,8 +131,13 @@ class SBCCallLeg : public CallLeg, public CredentialHolder
131 131
 
132 132
   // SBC interface usable from CC modules
133 133
 
134
-  void setLocalParty(const string &party, const string &uri) { dlg.local_party = party; dlg.local_uri = uri; }
135
-  void setRemoteParty(const string &party, const string &uri) { dlg.remote_party = party; dlg.remote_uri = uri; }
134
+  void setLocalParty(const string &party, const string &uri) { 
135
+    dlg->local_party = party; dlg->local_uri = uri; 
136
+  }
137
+
138
+  void setRemoteParty(const string &party, const string &uri) { 
139
+    dlg->remote_party = party; dlg->remote_uri = uri; 
140
+  }
136 141
 
137 142
   SBCCallProfile &getCallProfile() { return call_profile; }
138 143
   CallStatus getCallStatus() { return CallLeg::getCallStatus(); }
... ...
@@ -95,7 +95,7 @@ void VoiceboxDialog::onSessionStart() {
95 95
 
96 96
 void VoiceboxDialog::onBye(const AmSipRequest& req)
97 97
 {
98
-  dlg.reply(req,200,"OK");
98
+  dlg->reply(req,200,"OK");
99 99
 
100 100
   closeMailbox();
101 101
   setStopped();
... ...
@@ -111,7 +111,7 @@ void VoiceboxDialog::process(AmEvent* ev)
111 111
 
112 112
     if (Bye == state) {
113 113
       closeMailbox();
114
-      dlg.bye();
114
+      dlg->bye();
115 115
       setStopped();
116 116
     }
117 117
 
... ...
@@ -796,7 +796,7 @@ void AnswerMachineDialog::onNoAudio()
796 796
   case 0: {
797 797
     // announcement mode - no recording
798 798
     if (MODE_ANN == vm_mode) {
799
-      dlg.bye();
799
+      dlg->bye();
800 800
       setStopped();
801 801
       return;
802 802
     }
... ...
@@ -815,7 +815,7 @@ void AnswerMachineDialog::onNoAudio()
815 815
     break;
816 816
     
817 817
   case 2:
818
-    dlg.bye();
818
+    dlg->bye();
819 819
     saveMessage();
820 820
     setStopped();
821 821
     break;
... ...
@@ -894,7 +894,7 @@ void AnswerMachineDialog::onSessionStart()
894 894
 
895 895
 void AnswerMachineDialog::onBye(const AmSipRequest& req)
896 896
 {
897
-  dlg.reply(req,200,"OK");
897
+  dlg->reply(req,200,"OK");
898 898
 
899 899
   setInOut(NULL, NULL);
900 900
   saveMessage();
... ...
@@ -71,7 +71,7 @@ WebConferenceDialog::~WebConferenceDialog()
71 71
   prompts.cleanup((long)this);
72 72
   play_list.flush();
73 73
   if (is_dialout || (InConference == state)) {
74
-    factory->updateStatus(is_dialout?dlg.user:conf_id, 
74
+    factory->updateStatus(is_dialout?dlg->user:conf_id, 
75 75
 			  getLocalTag(), 
76 76
 			  ConferenceRoomParticipant::Finished,
77 77
 			  "");
... ...
@@ -148,7 +148,7 @@ void WebConferenceDialog::onSessionStart() {
148 148
 	prompts.addToPlaylist(ENTER_PIN,  (long)this, play_list);
149 149
       } else {
150 150
 	DBG("########## direct connect conference '%s'  #########\n", conf_id.c_str());
151
-	if (!factory->newParticipant(conf_id, getLocalTag(), dlg.remote_party,
151
+	if (!factory->newParticipant(conf_id, getLocalTag(), dlg->remote_party,
152 152
 				     participant_id)) {
153 153
 	  DBG("inexisting conference room '%s\n", conf_id.c_str());
154 154
 	  state = PlayErrorFinish;
... ...
@@ -164,11 +164,11 @@ void WebConferenceDialog::onSessionStart() {
164 164
       }
165 165
     } else {
166 166
       setMute(false);
167
-      DBG("########## dialout: connect to conference '%s' #########\n", dlg.user.c_str()); 
167
+      DBG("########## dialout: connect to conference '%s' #########\n", dlg->user.c_str()); 
168 168
       state = InConference;
169 169
       setLocalInput(NULL);
170 170
       time(&connect_ts);
171
-      connectConference(dlg.user);
171
+      connectConference(dlg->user);
172 172
     }
173 173
   }
174 174
 
... ...
@@ -178,7 +178,7 @@ void WebConferenceDialog::onSessionStart() {
178 178
 void WebConferenceDialog::onRinging(const AmSipReply& rep) { 
179 179
   if (None == state || InConferenceEarly == state) {
180 180
     DBG("########## dialout: connect ringing session to conference '%s'  #########\n", 
181
-	dlg.user.c_str()); 
181
+	dlg->user.c_str()); 
182 182
 
183 183
     if(!RingTone.get())
184 184
       RingTone.reset(new AmRingTone(0,2000,4000,440,480)); // US
... ...
@@ -186,7 +186,7 @@ void WebConferenceDialog::onRinging(const AmSipReply& rep) {
186 186
     setLocalInput(RingTone.get());
187 187
 
188 188
     if (None == state) {
189
-      connectConference(dlg.user);
189
+      connectConference(dlg->user);
190 190
     }
191 191
     state = InConferenceRinging;
192 192
   }
... ...
@@ -197,10 +197,10 @@ void WebConferenceDialog::onEarlySessionStart() {
197 197
   if (None == state || InConferenceRinging == state) {
198 198
 
199 199
     DBG("########## dialout: connect early session to conference '%s'  #########\n", 
200
-	dlg.user.c_str());
200
+	dlg->user.c_str());
201 201
     setLocalInput(NULL);
202 202
     if (None == state) {
203
-      connectConference(dlg.user);
203
+      connectConference(dlg->user);
204 204
     }
205 205
     //    setMute(true);
206 206
 
... ...
@@ -219,10 +219,10 @@ void WebConferenceDialog::onSipReply(const AmSipRequest& req,
219 219
   DBG("reply: %u %s, old_dlg_status = %s, status = %s\n",
220 220
       reply.code, reply.reason.c_str(),
221 221
       AmBasicSipDialog::getStatusStr(old_dlg_status),
222
-      dlg.getStatusStr());
222
+      dlg->getStatusStr());
223 223
 
224 224
   if ((old_dlg_status < AmSipDialog::Connected) && 
225
-      (dlg.getStatus() == AmSipDialog::Disconnected)) {
225
+      (dlg->getStatus() == AmSipDialog::Disconnected)) {
226 226
     DBG("Call failed.\n");
227 227
     setStopped();
228 228
   }
... ...
@@ -232,7 +232,7 @@ void WebConferenceDialog::onSipReply(const AmSipRequest& req,
232 232
     // map AmSipDialog state to WebConferenceState
233 233
     ConferenceRoomParticipant::ParticipantStatus rep_st = 
234 234
       ConferenceRoomParticipant::Connecting;
235
-    switch (dlg.getStatus()) {
235
+    switch (dlg->getStatus()) {
236 236
     case AmSipDialog::Trying:
237 237
     case AmSipDialog::Proceeding:
238 238
     case AmSipDialog::Early:
... ...
@@ -251,7 +251,7 @@ void WebConferenceDialog::onSipReply(const AmSipRequest& req,
251 251
     default:break;
252 252
     }
253 253
     DBG("is dialout: updateing status\n");
254
-    factory->updateStatus(dlg.user, getLocalTag(), 
254
+    factory->updateStatus(dlg->user, getLocalTag(), 
255 255
 			  rep_st, int2str(reply.code) + " " + reply.reason);
256 256
   }
257 257
 }
... ...
@@ -323,7 +323,7 @@ void WebConferenceDialog::process(AmEvent* ev)
323 323
       state = InConference;
324 324
       DBG("########## connectConference after pin entry #########\n");
325 325
 
326
-      if (!factory->newParticipant(pin_str, getLocalTag(), dlg.remote_party,
326
+      if (!factory->newParticipant(pin_str, getLocalTag(), dlg->remote_party,
327 327
 				   participant_id)) {
328 328
 	DBG("inexisting conference room '%s'\n", pin_str.c_str());
329 329
 	state = PlayErrorFinish;
... ...
@@ -346,7 +346,7 @@ void WebConferenceDialog::process(AmEvent* ev)
346 346
     DBG("########## noAudio event #########\n");
347 347
     if (PlayErrorFinish == state) {
348 348
       DBG("Finished playing bye message, ending call.\n");
349
-      dlg.bye();
349
+      dlg->bye();
350 350
       setStopped();
351 351
       return;
352 352
     }
... ...
@@ -406,7 +406,7 @@ void WebConferenceDialog::onDtmf(int event, int duration) {
406 406
 
407 407
 void WebConferenceDialog::onKicked() {
408 408
   DBG("########## WebConference::onKick #########\n");
409
-  dlg.bye(); 
409
+  dlg->bye(); 
410 410
   disconnectConference();
411 411
   factory->updateStatus(conf_id, getLocalTag(), ConferenceRoomParticipant::Disconnecting,
412 412
 			"disconnect");
... ...
@@ -112,7 +112,7 @@ void AmB2ABSession::onBye(const AmSipRequest& req) {
112 112
 
113 113
 void AmB2ABSession::terminateLeg()
114 114
 {
115
-  dlg.bye();
115
+  dlg->bye();
116 116
   disconnectSession();
117 117
   setStopped();
118 118
 }
... ...
@@ -245,9 +245,9 @@ void AmB2ABCallerSession::setupCalleeSession(AmB2ABCalleeSession* callee_session
245 245
   //  return;
246 246
   assert(callee_session);
247 247
 
248
-  AmSipDialog& callee_dlg = callee_session->dlg;
249
-  callee_dlg.callid       = AmSession::getNewId();
250
-  callee_dlg.local_tag    = other_id;
248
+  AmSipDialog* callee_dlg = callee_session->dlg;
249
+  callee_dlg->callid       = AmSession::getNewId();
250
+  callee_dlg->local_tag    = other_id;
251 251
 
252 252
 
253 253
   MONITORING_LOG(other_id.c_str(), 
... ...
@@ -298,11 +298,11 @@ void AmB2ABCalleeSession::onB2ABEvent(B2ABEvent* ev)
298 298
 		      "to",      co_ev->remote_party.c_str(),
299 299
 		      "ruri",    co_ev->remote_uri.c_str());
300 300
 
301
-      dlg.local_party  = co_ev->local_party;
302
-      dlg.local_uri    = co_ev->local_uri;
301
+      dlg->local_party  = co_ev->local_party;
302
+      dlg->local_uri    = co_ev->local_uri;
303 303
 			
304
-      dlg.remote_party = co_ev->remote_party;
305
-      dlg.remote_uri   = co_ev->remote_uri;
304
+      dlg->remote_party = co_ev->remote_party;
305
+      dlg->remote_uri   = co_ev->remote_uri;
306 306
 
307 307
       setCallgroup(co_ev->callgroup);
308 308
 			
... ...
@@ -354,7 +354,7 @@ void AmB2ABCalleeSession::onSessionStart() {
354 354
 void AmB2ABCalleeSession::onSipReply(const AmSipRequest& req, const AmSipReply& rep,
355 355
 				     AmBasicSipDialog::Status old_dlg_status) {
356 356
   AmB2ABSession::onSipReply(req, rep, old_dlg_status);
357
-  AmSipDialog::Status status = dlg.getStatus();
357
+  AmSipDialog::Status status = dlg->getStatus();
358 358
  
359 359
   if ((old_dlg_status == AmSipDialog::Trying) ||
360 360
       (old_dlg_status == AmSipDialog::Proceeding) ||
... ...
@@ -125,7 +125,7 @@ void AmB2BSession::relayError(const string &method, unsigned cseq, bool forward,
125 125
     errCode2RelayedReply(n_reply, err_code, 500);
126 126
     n_reply.cseq = cseq;
127 127
     n_reply.cseq_method = method;
128
-    n_reply.from_tag = dlg.local_tag;
128
+    n_reply.from_tag = dlg->local_tag;
129 129
     DBG("relaying B2B SIP error reply %u %s\n", n_reply.code, n_reply.reason.c_str());
130 130
     relayEvent(new B2BSipReplyEvent(n_reply, forward, method));
131 131
   }
... ...
@@ -139,7 +139,7 @@ void AmB2BSession::relayError(const string &method, unsigned cseq, bool forward,
139 139
     n_reply.reason = reason;
140 140
     n_reply.cseq = cseq;
141 141
     n_reply.cseq_method = method;
142
-    n_reply.from_tag = dlg.local_tag;
142
+    n_reply.from_tag = dlg->local_tag;
143 143
     DBG("relaying B2B SIP reply %d %s\n", sip_code, reason);
144 144
     relayEvent(new B2BSipReplyEvent(n_reply, forward, method));
145 145
   }
... ...
@@ -162,7 +162,7 @@ void AmB2BSession::onB2BEvent(B2BEvent* ev)
162 162
       if(req_ev->forward){
163 163
 
164 164
 	if (req_ev->req.method == SIP_METH_INVITE &&
165
-	    dlg.getUACInvTransPending()) {
165
+	    dlg->getUACInvTransPending()) {
166 166
 	  // don't relay INVITE if INV trans pending
167 167
           relayError(req_ev->req.method, req_ev->req.cseq, true, 491, SIP_REPLY_PENDING);
168 168
 	  return;
... ...
@@ -241,7 +241,7 @@ void AmB2BSession::onB2BEvent(B2BEvent* ev)
241 241
 	     reply_ev->reply.cseq_method == SIP_METH_UPDATE)) {
242 242
 	  if (updateSessionDescription(reply_ev->reply.body)) {
243 243
 	    if (reply_ev->reply.cseq != est_invite_cseq) {
244
-	      if (dlg.getUACInvTransPending()) {
244
+	      if (dlg->getUACInvTransPending()) {
245 245
 		DBG("changed session, but UAC INVITE trans pending\n");
246 246
 		// todo(?): save until trans is finished?
247 247
 		return;
... ...
@@ -314,7 +314,7 @@ void AmB2BSession::onSipRequest(const AmSipRequest& req)
314 314
     if (parseSdp(sdp, req)) {
315 315
       if (!updateRemoteSdp(sdp)) {
316 316
         ERROR("media update failed, reply internal error\n");
317
-        dlg.reply(req, 500, SIP_REPLY_SERVER_INTERNAL_ERROR);
317
+        dlg->reply(req, 500, SIP_REPLY_SERVER_INTERNAL_ERROR);
318 318
 
319 319
         return;
320 320
       }
... ...
@@ -345,7 +345,7 @@ void AmB2BSession::onSipRequest(const AmSipRequest& req)
345 345
       ERROR("relay failed, replying error\n");
346 346
       AmSipReply n_reply;
347 347
       errCode2RelayedReply(n_reply, res, 500);
348
-      dlg.reply(req, n_reply.code, n_reply.reason);
348
+      dlg->reply(req, n_reply.code, n_reply.reason);
349 349
     }
350 350
 
351 351
     return;
... ...
@@ -546,7 +546,7 @@ void AmB2BSession::terminateLeg()
546 546
 
547 547
   clearRtpReceiverRelay();
548 548
 
549
-  dlg.bye("", SIP_FLAGS_VERBATIM);
549
+  dlg->bye("", SIP_FLAGS_VERBATIM);
550 550
 }
551 551
 
552 552
 void AmB2BSession::terminateOtherLeg()
... ...
@@ -656,7 +656,7 @@ int AmB2BSession::sendEstablishedReInvite() {
656 656
       body = &r_body; // should we keep the old one intact???
657 657
     }
658 658
 
659
-    return dlg.reinvite("", body,
659
+    return dlg->reinvite("", body,
660 660
 			SIP_FLAGS_VERBATIM);
661 661
   } catch (const string& s) {
662 662
     ERROR("sending established SDP reinvite: %s\n", s.c_str());
... ...
@@ -666,7 +666,7 @@ int AmB2BSession::sendEstablishedReInvite() {
666 666
 
667 667
 bool AmB2BSession::refresh(int flags) {
668 668
   // no session refresh if not connected
669
-  if (dlg.getStatus() != AmSipDialog::Connected)
669
+  if (dlg->getStatus() != AmSipDialog::Connected)
670 670
     return false;
671 671
 
672 672
   DBG(" AmB2BSession::refresh: refreshing session\n");
... ...
@@ -678,7 +678,7 @@ bool AmB2BSession::refresh(int flags) {
678 678
   }
679 679
 
680 680
   // refresh with re-INVITE
681
-  if (dlg.getUACInvTransPending()) {
681
+  if (dlg->getUACInvTransPending()) {
682 682
     DBG("INVITE transaction pending - not refreshing now\n");
683 683
     return false;
684 684
   }
... ...
@@ -688,7 +688,7 @@ bool AmB2BSession::refresh(int flags) {
688 688
 int AmB2BSession::relaySip(const AmSipRequest& req)
689 689
 {
690