34 _LIT(KTraceFileName,"SUPL_PH_API::epos_csuplcommunicationmanager.cpp"); |
34 _LIT(KTraceFileName,"SUPL_PH_API::epos_csuplcommunicationmanager.cpp"); |
35 |
35 |
36 |
36 |
37 // ============================ MEMBER FUNCTIONS =============================== |
37 // ============================ MEMBER FUNCTIONS =============================== |
38 |
38 |
39 CSuplCommunicationManager::CSuplCommunicationManager(): |
39 CSuplCommunicationManager::CSuplCommunicationManager(MSuplConnectionMonitor& aConnMonitor): |
40 iServerConnected(EFalse) |
40 iServerConnected(EFalse), iConnMonitor(aConnMonitor) |
41 { |
41 { |
42 } |
42 } |
43 |
43 |
44 void CSuplCommunicationManager::ConstructL() |
44 void CSuplCommunicationManager::ConstructL() |
45 { |
45 { |
47 iTrace = CSuplConnTrace::NewL(); |
47 iTrace = CSuplConnTrace::NewL(); |
48 |
48 |
49 iTrace->Trace(_L("CSuplCommunicationManager::ConstructL"), KTraceFileName, __LINE__); |
49 iTrace->Trace(_L("CSuplCommunicationManager::ConstructL"), KTraceFileName, __LINE__); |
50 } |
50 } |
51 |
51 |
52 EXPORT_C CSuplCommunicationManager* CSuplCommunicationManager::NewL() |
52 EXPORT_C CSuplCommunicationManager* CSuplCommunicationManager::NewL(MSuplConnectionMonitor& aConnMonitor) |
53 { |
53 { |
54 CSuplCommunicationManager* self = new( ELeave ) CSuplCommunicationManager; |
54 CSuplCommunicationManager* self = new( ELeave ) CSuplCommunicationManager(aConnMonitor); |
55 |
55 |
56 CleanupStack::PushL( self ); |
56 CleanupStack::PushL( self ); |
57 self->ConstructL(); |
57 self->ConstructL(); |
58 CleanupStack::Pop(); |
58 CleanupStack::Pop(); |
59 |
59 |
123 CSuplConnection *suplConnection = NULL; |
123 CSuplConnection *suplConnection = NULL; |
124 |
124 |
125 if(NULL == (suplConnection = FindConnection(aHostAddress, aPort))) |
125 if(NULL == (suplConnection = FindConnection(aHostAddress, aPort))) |
126 { |
126 { |
127 suplConnection = CSuplConnection::NewL(iSocketServ, aHostAddress, aPort, aIAPId, this); |
127 suplConnection = CSuplConnection::NewL(iSocketServ, aHostAddress, aPort, aIAPId, this); |
128 iConnArray.Append(suplConnection); |
128 iConnArray.AppendL(suplConnection); |
129 iTrace->Trace(_L("CSuplCommunicationManager::CreateConnectionL New Connection Created"), KTraceFileName, __LINE__); |
129 iTrace->Trace(_L("CSuplCommunicationManager::CreateConnectionL New Connection Created"), KTraceFileName, __LINE__); |
130 } |
130 iConnMonitor.ConnectionOpened(); |
|
131 } |
131 else |
132 else |
132 { |
133 { |
133 // Check if we have exceeded the max no. of sessions |
134 // Check if we have exceeded the max no. of sessions |
134 // for this conenction |
135 // for this conenction |
135 TBuf<64> msg(_L("RefCount in CreateConnectionL")); |
136 TBuf<64> msg(_L("RefCount in CreateConnectionL")); |
136 msg.AppendNum(suplConnection->RefCount()); |
137 msg.AppendNum(suplConnection->RefCount()); |
137 iTrace->Trace(msg, KTraceFileName, __LINE__); |
138 iTrace->Trace(msg, KTraceFileName, __LINE__); |
138 if(suplConnection->RefCount() >= KMaxSessionPerConn) |
139 if(suplConnection->RefCount() >= KMaxSessionPerConn) |
139 { |
140 { |
140 suplConnection = CSuplConnection::NewL(iSocketServ, aHostAddress, aPort, aIAPId, this); |
141 suplConnection = CSuplConnection::NewL(iSocketServ, aHostAddress, aPort, aIAPId, this); |
141 iConnArray.Append(suplConnection); |
142 iConnArray.AppendL(suplConnection); |
142 iTrace->Trace(_L("CSuplCommunicationManager::CreateConnectionL New Connection Created"), KTraceFileName, __LINE__); |
143 iTrace->Trace(_L("CSuplCommunicationManager::CreateConnectionL New Connection Created"), KTraceFileName, __LINE__); |
143 } |
144 iConnMonitor.ConnectionOpened(); |
144 } |
145 } |
|
146 } |
145 |
147 |
146 // Increment the Ref Count |
148 // Increment the Ref Count |
147 suplConnection->IncRefCount(); |
149 suplConnection->IncRefCount(); |
148 |
150 |
149 return suplConnection; |
151 return suplConnection; |
178 CSuplConnection *suplConnection = NULL; |
180 CSuplConnection *suplConnection = NULL; |
179 |
181 |
180 if(NULL == (suplConnection = FindConnection(aHostAddress, aPort))) |
182 if(NULL == (suplConnection = FindConnection(aHostAddress, aPort))) |
181 { |
183 { |
182 suplConnection = CSuplConnection::NewL(iSocketServ, aHostAddress, aPort, aIAPId, aTls, aPskTls, this); |
184 suplConnection = CSuplConnection::NewL(iSocketServ, aHostAddress, aPort, aIAPId, aTls, aPskTls, this); |
183 iConnArray.Append(suplConnection); |
185 iConnArray.AppendL(suplConnection); |
|
186 iConnMonitor.ConnectionOpened(); |
184 iTrace->Trace(_L("CSuplCommunicationManager::CreateConnectionL New Connection Created"), KTraceFileName, __LINE__); |
187 iTrace->Trace(_L("CSuplCommunicationManager::CreateConnectionL New Connection Created"), KTraceFileName, __LINE__); |
185 } |
188 } |
186 else |
189 else |
187 { |
190 { |
188 // Check if we have exceeded the max no. of sessions |
191 // Check if we have exceeded the max no. of sessions |
191 msg.AppendNum(suplConnection->RefCount()); |
194 msg.AppendNum(suplConnection->RefCount()); |
192 iTrace->Trace(msg, KTraceFileName, __LINE__); |
195 iTrace->Trace(msg, KTraceFileName, __LINE__); |
193 if(suplConnection->RefCount() >= KMaxSessionPerConn) |
196 if(suplConnection->RefCount() >= KMaxSessionPerConn) |
194 { |
197 { |
195 suplConnection = CSuplConnection::NewL(iSocketServ, aHostAddress, aPort, aIAPId, aTls, aPskTls, this); |
198 suplConnection = CSuplConnection::NewL(iSocketServ, aHostAddress, aPort, aIAPId, aTls, aPskTls, this); |
196 iConnArray.Append(suplConnection); |
199 iConnArray.AppendL(suplConnection); |
|
200 iConnMonitor.ConnectionOpened(); |
197 iTrace->Trace(_L("CSuplCommunicationManager::CreateConnectionL New Connection Created"), KTraceFileName, __LINE__); |
201 iTrace->Trace(_L("CSuplCommunicationManager::CreateConnectionL New Connection Created"), KTraceFileName, __LINE__); |
198 } |
202 } |
199 } |
203 } |
200 |
204 |
201 // Increment the Ref Count |
205 // Increment the Ref Count |
202 suplConnection->IncRefCount(); |
206 suplConnection->IncRefCount(); |
203 |
207 |
204 return suplConnection; |
208 return suplConnection; |
240 RemoveConnection(index); |
244 RemoveConnection(index); |
241 |
245 |
242 //Last Session invoking Destroy |
246 //Last Session invoking Destroy |
243 iTrace->Trace(_L("CSuplCommunicationManager::DestroyConnection Destroy Connection"), KTraceFileName, __LINE__); |
247 iTrace->Trace(_L("CSuplCommunicationManager::DestroyConnection Destroy Connection"), KTraceFileName, __LINE__); |
244 aConnection->Destroy(); |
248 aConnection->Destroy(); |
|
249 |
|
250 iConnMonitor.ConnectionClosed(); |
245 |
251 |
246 return KErrNone; |
252 return KErrNone; |
247 } |
253 } |
248 |
254 |
249 // ----------------------------------------------------------------------------- |
255 // ----------------------------------------------------------------------------- |