Browse code

propagate app_name to everywhere it is needed.

Raphael Coeffic authored on 10/05/2011 14:36:36
Showing 43 changed files
... ...
@@ -73,7 +73,7 @@ int AnnounceB2BFactory::onLoad()
73 73
   return 0;
74 74
 }
75 75
 
76
-AmSession* AnnounceB2BFactory::onInvite(const AmSipRequest& req)
76
+AmSession* AnnounceB2BFactory::onInvite(const AmSipRequest& req, const string& app_name)
77 77
 {
78 78
   string announce_path = AnnouncePath;
79 79
   string announce_file = announce_path + req.domain
... ...
@@ -44,7 +44,7 @@ public:
44 44
   AnnounceB2BFactory(const string& _app_name);
45 45
 
46 46
   int onLoad();
47
-  AmSession* onInvite(const AmSipRequest& req);
47
+  AmSession* onInvite(const AmSipRequest& req, const string& app_name);
48 48
 };
49 49
 
50 50
 /** \brief Session logic implementation of A leg in announce_b2b sessions */
... ...
@@ -68,7 +68,7 @@ int AnnounceTransferFactory::onLoad()
68 68
   return 0;
69 69
 }
70 70
 
71
-AmSession* AnnounceTransferFactory::onInvite(const AmSipRequest& req)
71
+AmSession* AnnounceTransferFactory::onInvite(const AmSipRequest& req, const string& app_name)
72 72
 {
73 73
   string announce_path = AnnouncePath;
74 74
   string announce_file = announce_path + req.domain 
... ...
@@ -44,7 +44,7 @@ public:
44 44
   AnnounceTransferFactory(const string& _app_name);
45 45
 
46 46
   int onLoad();
47
-  AmSession* onInvite(const AmSipRequest& req);
47
+  AmSession* onInvite(const AmSipRequest& req, const string& app_name);
48 48
 };
49 49
 
50 50
 /** \brief session logic implementation for announce_transfer sessions */
... ...
@@ -92,12 +92,12 @@ string AnnouncementFactory::getAnnounceFile(const AmSipRequest& req) {
92 92
   return announce_file;
93 93
 }
94 94
 
95
-AmSession* AnnouncementFactory::onInvite(const AmSipRequest& req)
95
+AmSession* AnnouncementFactory::onInvite(const AmSipRequest& req, const string& app_name)
96 96
 {
97 97
   return new AnnouncementDialog(getAnnounceFile(req), NULL);
98 98
 }
99 99
 
100
-AmSession* AnnouncementFactory::onInvite(const AmSipRequest& req,
100
+AmSession* AnnouncementFactory::onInvite(const AmSipRequest& req, const string& app_name,
101 101
 					 AmArg& session_params)
102 102
 {
103 103
   UACAuthCred* cred = NULL;
... ...
@@ -49,8 +49,8 @@ public:
49 49
   AnnouncementFactory(const string& _app_name);
50 50
 
51 51
   int onLoad();
52
-  AmSession* onInvite(const AmSipRequest& req);
53
-  AmSession* onInvite(const AmSipRequest& req,
52
+  AmSession* onInvite(const AmSipRequest& req, const string& app_name);
53
+  AmSession* onInvite(const AmSipRequest& req, const string& app_name,
54 54
 		      AmArg& session_params);
55 55
 
56 56
 };
... ...
@@ -204,14 +204,14 @@ void AnnRecorderFactory::getAppParams(const AmSipRequest& req, map<string, strin
204 204
   params["type"] = typ;
205 205
 }
206 206
 
207
-AmSession* AnnRecorderFactory::onInvite(const AmSipRequest& req)
207
+AmSession* AnnRecorderFactory::onInvite(const AmSipRequest& req, const string& app_name)
208 208
 {
209 209
   map<string, string> params;
210 210
   getAppParams(req, params);
211 211
   return new AnnRecorderDialog(params, prompts, NULL);
212 212
 }
213 213
 
214
-AmSession* AnnRecorderFactory::onInvite(const AmSipRequest& req,
214
+AmSession* AnnRecorderFactory::onInvite(const AmSipRequest& req, const string& app_name,
215 215
 					 AmArg& session_params)
216 216
 {
217 217
   UACAuthCred* cred = NULL;
... ...
@@ -74,8 +74,8 @@ public:
74 74
   AnnRecorderFactory(const string& _app_name);
75 75
 
76 76
   int onLoad();
77
-  AmSession* onInvite(const AmSipRequest& req);
78
-  AmSession* onInvite(const AmSipRequest& req,
77
+  AmSession* onInvite(const AmSipRequest& req, const string& app_name);
78
+  AmSession* onInvite(const AmSipRequest& req, const string& app_name,
79 79
 		      AmArg& session_params);
80 80
 
81 81
 };
... ...
@@ -125,7 +125,7 @@ int CallBackFactory::onLoad()
125 125
 }
126 126
 
127 127
 // incoming calls 
128
-AmSession* CallBackFactory::onInvite(const AmSipRequest& req)
128
+AmSession* CallBackFactory::onInvite(const AmSipRequest& req, const string& app_name)
129 129
 {
130 130
   // or req.from -> with display name ? 
131 131
   DBG("received INVITE from '%s'\n", req.from_uri.c_str());
... ...
@@ -156,7 +156,7 @@ AmSession* CallBackFactory::onInvite(const AmSipRequest& req)
156 156
 }
157 157
 
158 158
 // outgoing calls 
159
-AmSession* CallBackFactory::onInvite(const AmSipRequest& req,
159
+AmSession* CallBackFactory::onInvite(const AmSipRequest& req, const string& app_name,
160 160
 				     AmArg& session_params)
161 161
 {
162 162
   UACAuthCred* cred = NULL;
... ...
@@ -72,8 +72,8 @@ public:
72 72
   static PlayoutType m_PlayoutType;
73 73
 
74 74
   CallBackFactory(const string& _app_name);
75
-  AmSession* onInvite(const AmSipRequest&);
76
-  AmSession* onInvite(const AmSipRequest& req,
75
+  AmSession* onInvite(const AmSipRequest&, const string& app_name);
76
+  AmSession* onInvite(const AmSipRequest& req, const string& app_name,
77 77
 		      AmArg& session_params);
78 78
   int onLoad();
79 79
 
... ...
@@ -102,7 +102,7 @@ string Click2DialFactory::getAnnounceFile(const AmSipRequest& req)
102 102
 }
103 103
 
104 104
 
105
-AmSession* Click2DialFactory::onInvite(const AmSipRequest& req, AmArg& session_params)
105
+AmSession* Click2DialFactory::onInvite(const AmSipRequest& req, const string& app_name, AmArg& session_params)
106 106
 {
107 107
   UACAuthCred* cred = NULL;
108 108
   string callee_uri, a_realm, a_user, a_pwd;
... ...
@@ -180,7 +180,7 @@ AmSession* Click2DialFactory::onInvite(const AmSipRequest& req, AmArg& session_p
180 180
 }
181 181
 
182 182
 
183
-AmSession* Click2DialFactory::onInvite(const AmSipRequest& req)
183
+AmSession* Click2DialFactory::onInvite(const AmSipRequest& req, const string& app_name)
184 184
 {
185 185
   return new C2DCallerDialog(req, getAnnounceFile(req), NULL, NULL);
186 186
 }
... ...
@@ -52,8 +52,8 @@ class Click2DialFactory: public AmSessionFactory
52 52
     Click2DialFactory(const string& _app_name);
53 53
 
54 54
     int onLoad();
55
-    AmSession* onInvite(const AmSipRequest& req);
56
-    AmSession* onInvite(const AmSipRequest& req, AmArg& session_params);
55
+    AmSession* onInvite(const AmSipRequest& req, const string& app_name);
56
+    AmSession* onInvite(const AmSipRequest& req, const string& app_name, AmArg& session_params);
57 57
 };
58 58
 
59 59
 class C2DCallerDialog: public AmB2BCallerSession, public CredentialHolder
... ...
@@ -308,7 +308,7 @@ int ConferenceFactory::onLoad()
308 308
   return 0;
309 309
 }
310 310
 
311
-AmSession* ConferenceFactory::onInvite(const AmSipRequest& req)
311
+AmSession* ConferenceFactory::onInvite(const AmSipRequest& req, const string& app_name)
312 312
 {
313 313
   if ((ConferenceFactory::MaxParticipants > 0) &&
314 314
       (AmConferenceStatus::getConferenceSize(req.user) >=
... ...
@@ -353,7 +353,7 @@ void ConferenceFactory::setupSessionTimer(AmSession* s) {
353 353
   }
354 354
 }
355 355
 
356
-AmSession* ConferenceFactory::onRefer(const AmSipRequest& req)
356
+AmSession* ConferenceFactory::onRefer(const AmSipRequest& req, const string& app_name)
357 357
 {
358 358
   if(req.to_tag.empty())
359 359
     throw AmSession::Exception(488,"Not accepted here");
... ...
@@ -93,8 +93,8 @@ public:
93 93
 #endif
94 94
 
95 95
   ConferenceFactory(const string& _app_name);
96
-  virtual AmSession* onInvite(const AmSipRequest&);
97
-  virtual AmSession* onRefer(const AmSipRequest& req);
96
+  virtual AmSession* onInvite(const AmSipRequest&, const string& app_name);
97
+  virtual AmSession* onRefer(const AmSipRequest& req, const string& app_name);
98 98
   virtual int onLoad();
99 99
 };
100 100
 
... ...
@@ -683,24 +683,26 @@ void DSMFactory::runMonitorAppSelect(const AmSipRequest& req, string& start_diag
683 683
 #undef FALLBACK_OR_EXCEPTION
684 684
 }
685 685
  
686
-AmSession* DSMFactory::onInvite(const AmSipRequest& req)
686
+AmSession* DSMFactory::onInvite(const AmSipRequest& req, const string& app_name)
687 687
 {
688 688
   string start_diag;
689 689
   map<string, string> vars;
690 690
 
691
-  //if (req.cmd == MOD_NAME) {
692
-  if (InboundStartDiag.empty()) {
693
-    ERROR("no inbound calls allowed\n");
694
-    throw AmSession::Exception(488, "Not Acceptable Here");
695
-  }
696
-  if (InboundStartDiag=="$(mon_select)") {
697
-    runMonitorAppSelect(req, start_diag, vars);
691
+  if (app_name == MOD_NAME) {
692
+    if (InboundStartDiag.empty()) {
693
+      ERROR("no inbound calls allowed\n");
694
+      throw AmSession::Exception(488, "Not Acceptable Here");
695
+    }
696
+    if (InboundStartDiag=="$(mon_select)") {
697
+      runMonitorAppSelect(req, start_diag, vars);
698
+    } else {
699
+      start_diag = InboundStartDiag;
700
+    }
698 701
   } else {
699
-    start_diag = InboundStartDiag;
702
+    start_diag = app_name;
700 703
   }
701
-  //} else {
702
-  //start_diag = req.cmd;
703
-  //}
704
+
705
+  DBG("start_diag = %s\n",start_diag.c_str());
704 706
 
705 707
   // determine run configuration for script
706 708
   DSMScriptConfig call_config;
... ...
@@ -728,20 +730,20 @@ AmSession* DSMFactory::onInvite(const AmSipRequest& req)
728 730
 }
729 731
 
730 732
 // outgoing call
731
-AmSession* DSMFactory::onInvite(const AmSipRequest& req,
733
+AmSession* DSMFactory::onInvite(const AmSipRequest& req, const string& app_name,
732 734
 				AmArg& session_params) 
733 735
 {
734 736
 
735 737
   string start_diag;
736 738
 
737
-  //if (req.cmd == MOD_NAME) {
738
-  if (OutboundStartDiag.empty()) {
739
-    ERROR("no outbound calls allowed\n");
740
-    throw AmSession::Exception(488, "Not Acceptable Here");
739
+  if (app_name == MOD_NAME) {
740
+    if (OutboundStartDiag.empty()) {
741
+      ERROR("no outbound calls allowed\n");
742
+      throw AmSession::Exception(488, "Not Acceptable Here");
743
+    }
744
+  } else {
745
+    start_diag = app_name;
741 746
   }
742
-  //} else {
743
-  //start_diag = req.cmd;
744
-  //}
745 747
 
746 748
   UACAuthCred* cred = NULL;
747 749
   map<string, string> vars;
... ...
@@ -136,8 +136,8 @@ public:
136 136
 
137 137
 
138 138
   int onLoad();
139
-  AmSession* onInvite(const AmSipRequest& req);
140
-  AmSession* onInvite(const AmSipRequest& req,
139
+  AmSession* onInvite(const AmSipRequest& req, const string& app_name);
140
+  AmSession* onInvite(const AmSipRequest& req, const string& app_name,
141 141
 		      AmArg& session_params);
142 142
   // DI
143 143
   // DI factory
... ...
@@ -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
... ...
@@ -61,7 +61,7 @@ public:
61 61
   EarlyAnnounceFactory(const string& _app_name);
62 62
 
63 63
   int onLoad();
64
-  AmSession* onInvite(const AmSipRequest& req);
64
+  AmSession* onInvite(const AmSipRequest& req, const string& app_name);
65 65
 };
66 66
 
67 67
 /** \brief session logic implementation for early_announce sessions */
... ...
@@ -558,7 +558,7 @@ void IvrFactory::setupSessionTimer(AmSession* s) {
558 558
  * Load a script using user name from URI.
559 559
  * Note: there is no default script.
560 560
  */
561
-AmSession* IvrFactory::onInvite(const AmSipRequest& req)
561
+AmSession* IvrFactory::onInvite(const AmSipRequest& req, const string& app_name)
562 562
 {
563 563
   // if(req.cmd != MOD_NAME)
564 564
   //   return newDlg(req.cmd);
... ...
@@ -108,7 +108,7 @@ class IvrFactory: public AmSessionFactory
108 108
   IvrFactory(const string& _app_name);
109 109
 
110 110
   int onLoad();
111
-  AmSession* onInvite(const AmSipRequest& req);
111
+  AmSession* onInvite(const AmSipRequest& req, const string& app_name);
112 112
 
113 113
   void addDeferredThread(PyObject* pyCallable);
114 114
 
... ...
@@ -53,7 +53,7 @@ int PrecodedFactory::onLoad()
53 53
     return 0;
54 54
 }
55 55
 
56
-AmSession* PrecodedFactory::onInvite(const AmSipRequest& req)
56
+AmSession* PrecodedFactory::onInvite(const AmSipRequest& req, const string& app_name)
57 57
 {
58 58
     return new PrecodedDialog(&precoded_file);
59 59
 }
... ...
@@ -42,7 +42,7 @@ public:
42 42
     PrecodedFactory(const string& _app_name);
43 43
 
44 44
     int onLoad();
45
-    AmSession* onInvite(const AmSipRequest& req);
45
+    AmSession* onInvite(const AmSipRequest& req, const string& app_name);
46 46
 };
47 47
 
48 48
 class PrecodedDialog : public AmSession
... ...
@@ -109,7 +109,7 @@ void RegistrationAgentFactory::postEvent(AmEvent* ev) {
109 109
   dialer.postEvent(ev);
110 110
 }
111 111
 
112
-AmSession* RegistrationAgentFactory::onInvite(const AmSipRequest& req)
112
+AmSession* RegistrationAgentFactory::onInvite(const AmSipRequest& req, const string& app_name)
113 113
 {
114 114
   return NULL;
115 115
 }
... ...
@@ -70,7 +70,7 @@ class RegistrationAgentFactory: public AmSessionFactory
70 70
   RegistrationAgentFactory(const string& _app_name);
71 71
 	
72 72
   int onLoad();
73
-  AmSession* onInvite(const AmSipRequest& req);
73
+  AmSession* onInvite(const AmSipRequest& req, const string& app_name);
74 74
   void postEvent(AmEvent* ev);
75 75
 };
76 76
 
... ...
@@ -164,7 +164,7 @@ string SBCFactory::getActiveProfileMatch(string& profile_rule, const AmSipReques
164 164
   return res;
165 165
 }
166 166
 
167
-AmSession* SBCFactory::onInvite(const AmSipRequest& req)
167
+AmSession* SBCFactory::onInvite(const AmSipRequest& req, const string& app_name)
168 168
 {
169 169
   AmUriParser ruri_parser, from_parser, to_parser;
170 170
 
... ...
@@ -72,7 +72,7 @@ class SBCFactory: public AmSessionFactory,
72 72
   ~SBCFactory();
73 73
 
74 74
   int onLoad();
75
-  AmSession* onInvite(const AmSipRequest& req);
75
+  AmSession* onInvite(const AmSipRequest& req, const string& app_name);
76 76
 
77 77
   static AmConfigReader cfg;
78 78
   static AmSessionEventHandlerFactory* session_timer_fact;
... ...
@@ -289,7 +289,7 @@ int VoiceboxFactory::onLoad()
289 289
 }
290 290
 
291 291
 // incoming calls 
292
-AmSession* VoiceboxFactory::onInvite(const AmSipRequest& req)
292
+AmSession* VoiceboxFactory::onInvite(const AmSipRequest& req, const string& app_name)
293 293
 {
294 294
   string user;
295 295
   string pin;
... ...
@@ -68,7 +68,7 @@ public:
68 68
 
69 69
   VoiceboxFactory(const string& _app_name);
70 70
 
71
-  AmSession* onInvite(const AmSipRequest&);
71
+  AmSession* onInvite(const AmSipRequest&, const string& app_name);
72 72
 //   AmSession* onInvite(const AmSipRequest& req,
73 73
 // 		      AmArg& session_params);
74 74
   int onLoad();
... ...
@@ -498,7 +498,7 @@ int AnswerMachineFactory::onLoad()
498 498
   return 0;
499 499
 }
500 500
 
501
-AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req)
501
+AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req, const string& app_name)
502 502
 {
503 503
   string language;
504 504
   string email;
... ...
@@ -100,7 +100,7 @@ public:
100 100
   AnswerMachineFactory(const string& _app_name);
101 101
 
102 102
   int onLoad();
103
-  AmSession* onInvite(const AmSipRequest& req);
103
+  AmSession* onInvite(const AmSipRequest& req, const string& app_name);
104 104
 };
105 105
 
106 106
 class AnswerMachineDialog : public AmSession
... ...
@@ -353,7 +353,7 @@ void WebConferenceFactory::setupSessionTimer(AmSession* s) {
353 353
 }
354 354
 
355 355
 // incoming calls 
356
-AmSession* WebConferenceFactory::onInvite(const AmSipRequest& req)
356
+AmSession* WebConferenceFactory::onInvite(const AmSipRequest& req, const string& app_name)
357 357
 {
358 358
   if (NULL != session_timer_f) {
359 359
     if (!session_timer_f->onInvite(req, cfg))
... ...
@@ -380,7 +380,7 @@ AmSession* WebConferenceFactory::onInvite(const AmSipRequest& req)
380 380
 }
381 381
 
382 382
 // outgoing calls 
383
-AmSession* WebConferenceFactory::onInvite(const AmSipRequest& req,
383
+AmSession* WebConferenceFactory::onInvite(const AmSipRequest& req, const string& app_name,
384 384
 					  AmArg& session_params)
385 385
 {
386 386
   UACAuthCred* cred = NULL;
... ...
@@ -145,8 +145,8 @@ public:
145 145
 
146 146
 
147 147
   WebConferenceFactory(const string& _app_name);
148
-  AmSession* onInvite(const AmSipRequest&);
149
-  AmSession* onInvite(const AmSipRequest& req,
148
+  AmSession* onInvite(const AmSipRequest&, const string& app_name);
149
+  AmSession* onInvite(const AmSipRequest& req, const string& app_name,
150 150
 		      AmArg& session_params);
151 151
   int onLoad();
152 152
 
... ...
@@ -48,22 +48,22 @@ AmSessionFactory::AmSessionFactory(const string& name)
48 48
 {
49 49
 }
50 50
 
51
-AmSession* AmSessionFactory::onInvite(const AmSipRequest& req, 
51
+AmSession* AmSessionFactory::onInvite(const AmSipRequest& req, const string& app_name,
52 52
 				      AmArg& session_params) {
53 53
   WARN(" discarding session parameters to new session.\n");
54
-  return onInvite(req);
54
+  return onInvite(req,app_name);
55 55
 }
56 56
 
57
-AmSession* AmSessionFactory::onRefer(const AmSipRequest& req)
57
+AmSession* AmSessionFactory::onRefer(const AmSipRequest& req, const string& app_name)
58 58
 {
59 59
   throw AmSession::Exception(488,"Not accepted here");
60 60
 }
61 61
 
62
-AmSession* AmSessionFactory::onRefer(const AmSipRequest& req, 
62
+AmSession* AmSessionFactory::onRefer(const AmSipRequest& req, const string& app_name,
63 63
 				     AmArg& session_params)
64 64
 {
65 65
   WARN(" discarding session parameters to new session.\n");
66
-  return onRefer(req);
66
+  return onRefer(req,app_name);
67 67
 }
68 68
 
69 69
 int AmSessionFactory::configureModule(AmConfigReader& cfg) {
... ...
@@ -143,7 +143,7 @@ class AmSessionFactory: public AmPluginFactory
143 143
    *   This method should not make any expensive
144 144
    *   processing as it would block the server.
145 145
    */
146
-  virtual AmSession* onInvite(const AmSipRequest& req)=0;
146
+  virtual AmSession* onInvite(const AmSipRequest& req, const string& app_name)=0;
147 147
 
148 148
   /**
149 149
    * Creates a dialog state on new request. Passes with 
... ...
@@ -155,7 +155,7 @@ class AmSessionFactory: public AmPluginFactory
155 155
    *   This method should not make any expensive
156 156
    *   processing as it would block the server.
157 157
    */
158
-  virtual AmSession* onInvite(const AmSipRequest& req, 
158
+  virtual AmSession* onInvite(const AmSipRequest& req, const string& app_name,
159 159
 			      AmArg& session_params);
160 160
 
161 161
   /**
... ...
@@ -166,7 +166,7 @@ class AmSessionFactory: public AmPluginFactory
166 166
    *   This method should not make any expensive
167 167
    *   processing as it would block the server.
168 168
    */
169
-  virtual AmSession* onRefer(const AmSipRequest& req);
169
+  virtual AmSession* onRefer(const AmSipRequest& req, const string& app_name);
170 170
 
171 171
   /**
172 172
    * Creates a dialog state on new REFER with local-tag.
... ...
@@ -177,7 +177,7 @@ class AmSessionFactory: public AmPluginFactory
177 177
    *   This method should not make any expensive
178 178
    *   processing as it would block the server.
179 179
    */
180
-  virtual AmSession* onRefer(const AmSipRequest& req, 
180
+  virtual AmSession* onRefer(const AmSipRequest& req, const string& app_name,
181 181
 			     AmArg& session_params);
182 182
 
183 183
   /**
... ...
@@ -774,40 +774,41 @@ bool AmPlugIn::registerApplication(const string& app_name, AmSessionFactory* f)
774 774
   return res;
775 775
 }
776 776
 
777
-AmSessionFactory* AmPlugIn::findSessionFactory(AmSipRequest& req)
777
+AmSessionFactory* AmPlugIn::findSessionFactory(const AmSipRequest& req, string& app_name)
778 778
 {
779
-    string app_name;
779
+    string m_app_name;
780 780
 
781 781
     switch (AmConfig::AppSelect) {
782 782
 	
783 783
     case AmConfig::App_RURIUSER:
784
-      app_name = req.user; 
784
+      m_app_name = req.user; 
785 785
       break;
786 786
     case AmConfig::App_APPHDR: 
787
-      app_name = getHeader(req.hdrs, APPNAME_HDR, true); 
787
+      m_app_name = getHeader(req.hdrs, APPNAME_HDR, true); 
788 788
       break;      
789 789
     case AmConfig::App_RURIPARAM: 
790
-      app_name = get_header_param(req.r_uri, "app");
790
+      m_app_name = get_header_param(req.r_uri, "app");
791 791
       break;
792 792
     case AmConfig::App_MAPPING:
793
-      app_name = ""; // no match if not found
794
-      run_regex_mapping(AmConfig::AppMapping, req.r_uri.c_str(), app_name);
793
+      m_app_name = ""; // no match if not found
794
+      run_regex_mapping(AmConfig::AppMapping, req.r_uri.c_str(), m_app_name);
795 795
       break;
796 796
     case AmConfig::App_SPECIFIED: 
797
-      app_name = AmConfig::Application; 
797
+      m_app_name = AmConfig::Application; 
798 798
       break;
799 799
     }
800 800
     
801
-    if (app_name.empty()) {
801
+    if (m_app_name.empty()) {
802 802
       ERROR("could not find any application matching configured criteria\n");
803 803
       return NULL;
804 804
     }
805 805
     
806
-    AmSessionFactory* session_factory = getFactory4App(app_name);
806
+    AmSessionFactory* session_factory = getFactory4App(m_app_name);
807 807
     if(!session_factory) {
808 808
       ERROR("AmPlugIn::findSessionFactory: application '%s' not found !\n", app_name.c_str());
809 809
     }
810 810
     
811
+    app_name = m_app_name;
811 812
     return session_factory;
812 813
 }
813 814
 
... ...
@@ -229,7 +229,7 @@ class AmPlugIn : public AmPayloadProviderInterface
229 229
    * Find the proper SessionFactory
230 230
    * for the given request.
231 231
    */
232
-  AmSessionFactory* findSessionFactory(AmSipRequest& req);
232
+  AmSessionFactory* findSessionFactory(const AmSipRequest& req, string& app_name);
233 233
 
234 234
   /**
235 235
    * Session event handler lookup function
... ...
@@ -206,7 +206,7 @@ void AmSessionContainer::destroySession(AmSession* s)
206 206
     }
207 207
 }
208 208
 
209
-string AmSessionContainer::startSessionUAC(AmSipRequest& req, const string& app_name, AmArg* session_params) {
209
+string AmSessionContainer::startSessionUAC(const AmSipRequest& req, string& app_name, AmArg* session_params) {
210 210
 
211 211
   auto_ptr<AmSession> session;
212 212
   try {
... ...
@@ -282,8 +282,9 @@ void AmSessionContainer::startSessionUAS(AmSipRequest& req)
282 282
   try {
283 283
       // Call-ID and From-Tag are unknown: it's a new session
284 284
       auto_ptr<AmSession> session;
285
+      string app_name;
285 286
 
286
-      session.reset(createSession(req));
287
+      session.reset(createSession(req,app_name));
287 288
       if(session.get() != 0){
288 289
 
289 290
 	// update session's local tag (ID) if not already set
... ...
@@ -380,8 +381,8 @@ bool AmSessionContainer::postEvent(const string& local_tag,
380 381
 
381 382
 }
382 383
 
383
-AmSession* AmSessionContainer::createSession(AmSipRequest& req,
384
-					     const string& app_name,
384
+AmSession* AmSessionContainer::createSession(const AmSipRequest& req,
385
+					     string& app_name,
385 386
 					     AmArg* session_params)
386 387
 {
387 388
   if (AmConfig::ShutdownMode) {
... ...
@@ -408,7 +409,7 @@ AmSession* AmSessionContainer::createSession(AmSipRequest& req,
408 409
   if(!app_name.empty())
409 410
       session_factory = AmPlugIn::instance()->getFactory4App(app_name);
410 411
   else
411
-      session_factory = AmPlugIn::instance()->findSessionFactory(req);
412
+      session_factory = AmPlugIn::instance()->findSessionFactory(req,app_name);
412 413
 
413 414
   if(!session_factory) {
414 415
 
... ...
@@ -421,14 +422,14 @@ AmSession* AmSessionContainer::createSession(AmSipRequest& req,
421 422
   AmSession* session = NULL;
422 423
   if (req.method == "INVITE") {
423 424
     if (NULL != session_params) 
424
-      session = session_factory->onInvite(req, *session_params);
425
+      session = session_factory->onInvite(req, app_name, *session_params);
425 426
     else 
426
-      session = session_factory->onInvite(req);
427
+      session = session_factory->onInvite(req, app_name);
427 428
   } else if (req.method == "REFER") {
428 429
     if (NULL != session_params) 
429
-      session = session_factory->onRefer(req, *session_params);
430
+      session = session_factory->onRefer(req, app_name, *session_params);
430 431
     else 
431
-      session = session_factory->onRefer(req);
432
+      session = session_factory->onRefer(req, app_name);
432 433
   }
433 434
 
434 435
   if(!session) {
... ...
@@ -98,8 +98,8 @@ class AmSessionContainer : public AmThread
98 98
    * @param req local request
99 99
    * @return a new session or NULL on error.
100 100
    */
101
-  AmSession* createSession(AmSipRequest& req, 
102
-			   const string& app_name = "",
101
+  AmSession* createSession(const AmSipRequest& req, 
102
+			   string& app_name,
103 103
 			   AmArg* session_params = NULL);
104 104
 
105 105
   /**
... ...
@@ -129,8 +129,8 @@ class AmSessionContainer : public AmThread
129 129
    * Constructs a new session and adds it to the active session container. 
130 130
    * @param req client's request
131 131
    */
132
-  string startSessionUAC(AmSipRequest& req, 
133
-			     const string& app_name,
132
+  string startSessionUAC(const AmSipRequest& req, 
133
+			 string& app_name,
134 134
 			 AmArg* session_params = NULL);
135 135
 
136 136
   /**
... ...
@@ -109,7 +109,8 @@ void AmSipDispatcher::handleSipMsg(AmSipRequest &req)
109 109
 
110 110
   } else {
111 111
 
112
-      AmSessionFactory* sess_fact = AmPlugIn::instance()->findSessionFactory(req);
112
+      string app_name;
113
+      AmSessionFactory* sess_fact = AmPlugIn::instance()->findSessionFactory(req,app_name);
113 114
       if(!sess_fact){
114 115
 
115 116
 	  AmSipDialog::reply_error(req,404,"Not found");
... ...
@@ -32,7 +32,7 @@
32 32
 #include "AmConfig.h"
33 33
 
34 34
 string AmUAC::dialout(const string& user,
35
-		      const string& app_name,
35
+		      string& app_name,
36 36
 		      const string& r_uri, 
37 37
 		      const string& from,
38 38
 		      const string& from_uri,
... ...
@@ -39,7 +39,7 @@ using std::string;
39 39
 class AmUAC {
40 40
  public:
41 41
   static string dialout(const string& user,
42
-			const string& app_name,
42
+			string& app_name,
43 43
 			const string& r_uri, 
44 44
 			const string& from,
45 45
 			const string& from_uri,
... ...
@@ -72,7 +72,7 @@ int EchoFactory::onLoad()
72 72
   return 0;
73 73
 }
74 74
 
75
-AmSession* EchoFactory::onInvite(const AmSipRequest& req)
75
+AmSession* EchoFactory::onInvite(const AmSipRequest& req, const string& app_name)
76 76
 {
77 77
   if (NULL != session_timer_f) {
78 78
     if (!session_timer_f->onInvite(req, conf))
... ...
@@ -41,7 +41,7 @@ class EchoFactory: public AmSessionFactory
41 41
 public:
42 42
   EchoFactory(const string& _app_name);
43 43
   virtual int onLoad();
44
-  virtual AmSession* onInvite(const AmSipRequest& req);
44
+  virtual AmSession* onInvite(const AmSipRequest& req, const string& app_name);
45 45
 };
46 46
 
47 47
 /** \brief echo session logic implementation */