|
1 /* |
|
2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 // INCLUDE FILES |
|
26 #include "senservicemanagerimpl.h" |
|
27 |
|
28 #include <SenIdentityProvider.h> |
|
29 #include <SenXmlUtils.h> |
|
30 #include <SenServiceConnection.h> // WSF error codes |
|
31 |
|
32 #include "senservicemanagerdefines.h" // IPC enumerations |
|
33 #include "sendebug.h" // filelogging MACROs |
|
34 #include "senlogger.h" |
|
35 #include "senguidgen.h" |
|
36 #include "senchunk.h" |
|
37 #include <SenCredential2.h> |
|
38 #include "senxmldebug.h" |
|
39 |
|
40 namespace |
|
41 { |
|
42 const TInt KMaxChunkNumDecimals = 64; |
|
43 _LIT8(KIdentityProviderName, "IdentityProvider"); |
|
44 } |
|
45 |
|
46 |
|
47 CSenServiceManagerImpl* CSenServiceManagerImpl::NewL() |
|
48 { |
|
49 CSenServiceManagerImpl* pNew = NewLC(); |
|
50 CleanupStack::Pop(); |
|
51 return(pNew) ; |
|
52 } |
|
53 |
|
54 CSenServiceManagerImpl* CSenServiceManagerImpl::NewLC() |
|
55 { |
|
56 CSenServiceManagerImpl* pNew = new (ELeave) CSenServiceManagerImpl(NULL); |
|
57 CleanupStack::PushL(pNew); |
|
58 pNew->ConstructL(); |
|
59 return pNew; |
|
60 } |
|
61 |
|
62 CSenServiceManagerImpl* CSenServiceManagerImpl::NewL(MSenAuthenticationProvider& aAuthProvider) |
|
63 { |
|
64 CSenServiceManagerImpl* pNew = NewLC(aAuthProvider); |
|
65 CleanupStack::Pop(); |
|
66 return(pNew) ; |
|
67 } |
|
68 |
|
69 CSenServiceManagerImpl* CSenServiceManagerImpl::NewLC(MSenAuthenticationProvider& aAuthProvider) |
|
70 { |
|
71 CSenServiceManagerImpl* pNew = new (ELeave) CSenServiceManagerImpl(&aAuthProvider); |
|
72 CleanupStack::PushL(pNew); |
|
73 pNew->ConstructL(); |
|
74 return pNew; |
|
75 } |
|
76 |
|
77 void CSenServiceManagerImpl::ConstructL() |
|
78 { |
|
79 TInt connAttemp = 0; |
|
80 TInt connErr = KErrGeneral; |
|
81 |
|
82 ipGenerator = CSenGuidGen::NewL(); |
|
83 ipChunkName = HBufC::NewL(KSenUuidMaxLength+KMaxChunkNumDecimals); |
|
84 |
|
85 TLSLOG_OPEN(KSenServiceManagerLogChannel, KSenServiceManagerLogLevel, KSenServiceManagerLogDir, KSenServiceManagerLogFile); |
|
86 connErr = iConnection.Connect(); |
|
87 |
|
88 while ( (connErr == KErrServerBusy || connErr == KErrServerTerminated) |
|
89 & connAttemp < KSenMaxClientConnectionOpeningAttempts ) |
|
90 { |
|
91 User::After(1000000); // wait for a second if server has been shut down |
|
92 connErr = iConnection.Connect(); |
|
93 connAttemp++; |
|
94 } |
|
95 if ( connErr != KErrNone ) |
|
96 { |
|
97 User::Leave( connErr ); |
|
98 } |
|
99 |
|
100 iConnectionID = iConnection.ConnectionID(); |
|
101 iConnection.SetChannel(KSenServiceManagerLogChannelBase+iConnectionID); |
|
102 //iTlsLogChannel = KSenServiceManagerLogChannelBase + iConnectionID; |
|
103 |
|
104 |
|
105 #ifdef _SENDEBUG |
|
106 RThread thread; |
|
107 RProcess process; |
|
108 TFileName logFile; |
|
109 logFile.Append( KSenServiceManagerLogFile().Left(KSenServiceManagerLogFile().Length()-4) ); // exclude ".log" file extension |
|
110 logFile.AppendNum( iConnectionID ); |
|
111 logFile.Append( KSenUnderline ); |
|
112 logFile.Append( process.Name().Left(32)); |
|
113 logFile.Append( KSenUnderline ); |
|
114 logFile.Append( thread.Name().Left(20)); |
|
115 logFile.Append( KSenServiceManagerLogFile().Right(4) ); // postfix with ".log" file extension |
|
116 |
|
117 // Open connection to the file logger server |
|
118 TLSLOG_OPEN(KSenServiceManagerLogChannelBase+iConnectionID, KSenServiceManagerLogLevel, KSenServiceManagerLogDir, logFile); |
|
119 TLSLOG_L(KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel,"CSenServiceManager::ConstructL - Log file opened"); |
|
120 TLSLOG_FORMAT((KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel , _L8("- Connection ID: (%d)"), iConnectionID)); |
|
121 TLSLOG_L(KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel,"- Service Manager client ready."); |
|
122 #endif |
|
123 |
|
124 iReader = CSenXmlReader::NewL(KXmlParserMimeType); // use libxml2 sax parser |
|
125 } |
|
126 |
|
127 CSenServiceManagerImpl::CSenServiceManagerImpl(MSenAuthenticationProvider* apAuthProvider) |
|
128 : iConnection(),//&iLog), |
|
129 iReader(NULL), |
|
130 iInBuffer(NULL,0), |
|
131 iOutBuffer(NULL,0), |
|
132 iInitialized(EFalse), |
|
133 ipGenerator(NULL), |
|
134 ipChunkName(NULL), |
|
135 iChunkNameNumber(0), |
|
136 ipAuthProvider(apAuthProvider), |
|
137 iConnectionID(KErrNotReady) //, |
|
138 // iTlsLogChannel(KSenServiceManagerLogChannelBase) |
|
139 { |
|
140 CActiveScheduler::Add(this); |
|
141 } |
|
142 |
|
143 CSenServiceManagerImpl::~CSenServiceManagerImpl() |
|
144 { |
|
145 TLSLOG_L(KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel,"CSenServiceManagerImpl::~CSenServiceManagerImpl"); |
|
146 Cancel(); // Causes call to DoCancel() |
|
147 iConnection.Close(); |
|
148 |
|
149 delete iReader; |
|
150 delete iOutBuf; |
|
151 delete ipGenerator; |
|
152 delete ipChunkName; |
|
153 |
|
154 // Close the log file and the connection to the server. |
|
155 TLSLOG(KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel,(_L("Log file closed."))); |
|
156 TLSLOG_CLOSE (KSenServiceManagerLogChannelBase+iConnectionID); |
|
157 TLSLOG_CLOSE (KSenServiceManagerLogChannel); |
|
158 } |
|
159 |
|
160 void CSenServiceManagerImpl::RunL() |
|
161 { |
|
162 |
|
163 } |
|
164 |
|
165 void CSenServiceManagerImpl::DoCancel() |
|
166 { |
|
167 TLSLOG(KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel,(_L("CSenServiceManagerImpl::DoCancel"))); |
|
168 } |
|
169 |
|
170 TInt CSenServiceManagerImpl::Identifier() |
|
171 { |
|
172 return iConnectionID; |
|
173 } |
|
174 |
|
175 /* |
|
176 RFileLogger* CSenServiceManagerImpl::Log() const |
|
177 { |
|
178 return (RFileLogger*) &iLog; |
|
179 } |
|
180 */ |
|
181 TPtrC CSenServiceManagerImpl::NextChunkNameL() //Codescannerwarnings |
|
182 { |
|
183 if(ipChunkName) |
|
184 { |
|
185 iChunkNameNumber++; |
|
186 TPtr chunkname = ipChunkName->Des(); |
|
187 chunkname.Zero(); |
|
188 |
|
189 HBufC* pRandomGuid = ipGenerator->GetRandomGuidLC(); |
|
190 TPtr idBuffer = pRandomGuid->Des(); |
|
191 if(idBuffer.Length()>KSenUuidPrefixLength) |
|
192 { |
|
193 chunkname.Append(idBuffer.Right(idBuffer.Length()-KSenUuidPrefixLength)); |
|
194 } |
|
195 CleanupStack::PopAndDestroy(); // pRandomGuid |
|
196 chunkname.AppendNum(iChunkNameNumber); |
|
197 |
|
198 // Remove dashes |
|
199 _LIT(KDash, "-"); |
|
200 TInt pos = chunkname.Find(KDash); |
|
201 while (pos != KErrNotFound) |
|
202 { |
|
203 chunkname.Replace(pos, KDash().Length(), KNullDesC); |
|
204 pos = chunkname.Find(KDash); |
|
205 } |
|
206 TLSLOG_FORMAT((KSenServiceManagerLogChannelBase+iConnectionID, KNormalLogLevel , _L("CSenServiceManagerImpl::NextChunkNameL(): %S"), &chunkname)); |
|
207 |
|
208 return chunkname; |
|
209 } |
|
210 else |
|
211 { |
|
212 return KNullDesC(); |
|
213 } |
|
214 } |
|
215 |
|
216 |
|
217 |
|
218 // Parameter aUri is contract of the service |
|
219 TInt CSenServiceManagerImpl::ServiceDescriptionsL(const TDesC8& aUri, |
|
220 RServiceDescriptionArray& aList) |
|
221 { |
|
222 TInt retVal(KErrNone); |
|
223 TPtrC8 descriptions; |
|
224 |
|
225 CSenChunk* pSenChunk = CSenChunk::NewLC(NextChunkNameL()); //Codescannerwarnings |
|
226 //pSenChunk->SetLogger(Log()); |
|
227 retVal = pSenChunk->CreateChunk(); |
|
228 if (retVal == KErrNone) |
|
229 { |
|
230 retVal = pSenChunk->DescToChunk(aUri); |
|
231 if (retVal == KErrNone) |
|
232 { |
|
233 retVal = iConnection.ServiceDescriptionsByUriL(*pSenChunk); |
|
234 if (retVal == KErrNone) |
|
235 { |
|
236 retVal = pSenChunk->DescFromChunk(descriptions); |
|
237 if(retVal == KErrNone) |
|
238 { |
|
239 retVal = ExtractServiceDescriptionsL(descriptions, aList); |
|
240 } |
|
241 } |
|
242 } |
|
243 } |
|
244 CleanupStack::PopAndDestroy(pSenChunk); // Close chunk |
|
245 return retVal; |
|
246 } |
|
247 |
|
248 TInt CSenServiceManagerImpl::ServiceDescriptionsL(MSenServiceDescription& aSD, |
|
249 RServiceDescriptionArray& aList) |
|
250 { |
|
251 TInt retVal(KErrNone); |
|
252 |
|
253 HBufC8* pPattern = aSD.AsXmlL(); |
|
254 CleanupStack::PushL(pPattern); |
|
255 |
|
256 TPtrC8 descriptions; |
|
257 |
|
258 CSenChunk* pSenChunk = CSenChunk::NewLC(NextChunkNameL()); //Codescannerwarnings |
|
259 //pSenChunk->SetLogger(Log()); |
|
260 retVal = pSenChunk->CreateChunk(); |
|
261 if (retVal == KErrNone) |
|
262 { |
|
263 retVal = pSenChunk->DescToChunk(*pPattern); |
|
264 if (retVal == KErrNone) |
|
265 { |
|
266 retVal = iConnection.ServiceDescriptionsByPatternL(*pSenChunk); |
|
267 if(retVal == KErrNone) |
|
268 { |
|
269 retVal = pSenChunk->DescFromChunk(descriptions); |
|
270 if(retVal == KErrNone) |
|
271 { |
|
272 retVal = ExtractServiceDescriptionsL(descriptions, aList); |
|
273 } |
|
274 } |
|
275 } |
|
276 } |
|
277 CleanupStack::PopAndDestroy(pSenChunk); // Close chunk |
|
278 |
|
279 // In any case, destroy the pattern as XML buffer: |
|
280 CleanupStack::PopAndDestroy(); // pPattern |
|
281 |
|
282 return retVal; |
|
283 } |
|
284 |
|
285 TInt CSenServiceManagerImpl::RegisterServiceDescriptionL(MSenServiceDescription& aSD) |
|
286 { |
|
287 // do not register if both endpoint and contract are |
|
288 // missing |
|
289 if(aSD.Endpoint().Length()==0 && aSD.Contract().Length()==0) |
|
290 { |
|
291 return KErrSenNoContractNoEndPoint; |
|
292 } |
|
293 |
|
294 else |
|
295 { |
|
296 _LIT8(KProviderID,"ProviderID"); |
|
297 HBufC8* pAsXml = NULL; |
|
298 if ( aSD.DescriptionClassType() == |
|
299 MSenServiceDescription::EIdentityProvider ) |
|
300 { |
|
301 TLSLOG(KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel,(_L("RegisterServiceDescriptionL with EIdentityProvider "))); |
|
302 |
|
303 CSenIdentityProvider* pIdP = (CSenIdentityProvider*)&aSD; |
|
304 |
|
305 CSenXmlServiceDescription* pSD = CSenXmlServiceDescription::NewLC( |
|
306 pIdP->Endpoint(), |
|
307 pIdP->Contract() ); |
|
308 |
|
309 pSD->SetFrameworkIdL( pIdP->FrameworkId() ); |
|
310 pSD->AsElement().AddElementL(KProviderID).SetContentL( |
|
311 pIdP->ProviderID() ); //CodeScannerWarnings |
|
312 |
|
313 pAsXml = pSD->AsXmlL(); // leaves if no memory available |
|
314 CleanupStack::PopAndDestroy(); // pSD |
|
315 } |
|
316 else // ServiceDescription |
|
317 { |
|
318 pAsXml = aSD.AsXmlL(); // leaves if no memory available |
|
319 } |
|
320 |
|
321 CleanupStack::PushL(pAsXml); // must be the first line after if-clause |
|
322 TPtr8 ptr = pAsXml->Des(); |
|
323 // now register the XML string (descriptor) to WSF Symbian server: |
|
324 TInt retVal(iConnection.RegisterServiceDescription(ptr)); |
|
325 CleanupStack::PopAndDestroy(); // pAsXml |
|
326 |
|
327 return retVal; |
|
328 } |
|
329 } |
|
330 |
|
331 TInt CSenServiceManagerImpl::UnregisterServiceDescriptionL( |
|
332 MSenServiceDescription& aSD) |
|
333 { |
|
334 // do not unregister if both endpoint and contract are |
|
335 // missing |
|
336 if(aSD.Endpoint().Length()==0 && aSD.Contract().Length()==0) |
|
337 { |
|
338 return KErrSenNoContractNoEndPoint; |
|
339 } |
|
340 else |
|
341 { |
|
342 HBufC8* pAsXml = NULL; |
|
343 if ( aSD.DescriptionClassType() == |
|
344 MSenServiceDescription::EIdentityProvider ) |
|
345 { |
|
346 TLSLOG(KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel,(_L("UnregisterServiceDescriptionL with EIdentityProvider "))); |
|
347 |
|
348 CSenIdentityProvider* pIdP = (CSenIdentityProvider*)&aSD; |
|
349 |
|
350 CSenXmlServiceDescription* pSD = |
|
351 CSenXmlServiceDescription::NewLC(pIdP->Endpoint(), |
|
352 pIdP->Contract()); |
|
353 |
|
354 pSD->SetFrameworkIdL( pIdP->FrameworkId() ); |
|
355 if(pIdP->ProviderID().Length()>0) |
|
356 { |
|
357 _LIT8(KProviderID,"ProviderID"); |
|
358 CSenElement& providerIdElement = |
|
359 pSD->AsElement().AddElementL(KProviderID); //CodeScannerWarnings |
|
360 providerIdElement.SetContentL(pIdP->ProviderID()); |
|
361 } |
|
362 pAsXml = pSD->AsXmlL(); // leaves if no memory available |
|
363 CleanupStack::PopAndDestroy(); // pSD |
|
364 } |
|
365 else // ServiceDescription |
|
366 { |
|
367 pAsXml = aSD.AsXmlL(); // leaves if no memory available |
|
368 } |
|
369 |
|
370 CleanupStack::PushL(pAsXml); // must be the first line after if-clause |
|
371 TPtr8 ptr = pAsXml->Des(); |
|
372 TInt retVal(iConnection.UnregisterServiceDescription(ptr)); |
|
373 CleanupStack::PopAndDestroy(); // pAsXml |
|
374 return retVal; |
|
375 } |
|
376 } |
|
377 // comment: remote developer interface to identity manager |
|
378 TInt CSenServiceManagerImpl::RegisterIdentityProviderL( |
|
379 CSenIdentityProvider& aProvider) |
|
380 { |
|
381 HBufC8* provider = aProvider.AsXmlL(); |
|
382 TPtr8 ptr = provider->Des(); |
|
383 TInt retVal = iConnection.RegisterIdentityProvider(ptr); |
|
384 delete provider; |
|
385 return retVal; |
|
386 } |
|
387 |
|
388 TInt CSenServiceManagerImpl::UnregisterIdentityProviderL( |
|
389 CSenIdentityProvider& aProvider) |
|
390 { |
|
391 HBufC8* provider = aProvider.AsXmlL(); |
|
392 TPtr8 ptr = provider->Des(); |
|
393 TInt retVal(iConnection.UnregisterIdentityProvider(ptr)); |
|
394 delete provider; |
|
395 return retVal; |
|
396 } |
|
397 |
|
398 TInt CSenServiceManagerImpl::AssociateServiceL(const TDesC8& aServiceID, |
|
399 const TDesC8& aProviderID) |
|
400 { |
|
401 if (aServiceID.Length() <= 0 || aProviderID.Length() <= 0) |
|
402 { |
|
403 return KErrArgument; |
|
404 } |
|
405 TInt retVal( iConnection.AssociateService( (TDesC8&)aServiceID, |
|
406 (TDesC8&)aProviderID) ); |
|
407 return retVal; |
|
408 } |
|
409 |
|
410 |
|
411 TInt CSenServiceManagerImpl::DissociateServiceL(const TDesC8& aServiceID, |
|
412 const TDesC8& aProviderID) |
|
413 { |
|
414 if (aServiceID.Length() <= 0 || aProviderID.Length() <= 0) |
|
415 { |
|
416 return KErrArgument; |
|
417 } |
|
418 TInt retVal( iConnection.DissociateService( (TDesC8&)aServiceID, |
|
419 (TDesC8&)aProviderID) ); |
|
420 return retVal; |
|
421 } |
|
422 |
|
423 TInt CSenServiceManagerImpl::InstallFrameworkL(const TDesC8& aFrameworkId) |
|
424 { |
|
425 TLSLOG(KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel,(_L("CSenServiceManager::InstallFrameworkL"))); |
|
426 TLSLOG(KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel,(aFrameworkId)); |
|
427 if (aFrameworkId.Length() <= 0) |
|
428 { |
|
429 return KErrArgument; |
|
430 } |
|
431 TInt retVal( iConnection.InstallFramework((TDesC8&)aFrameworkId) ); |
|
432 |
|
433 return retVal; |
|
434 } |
|
435 |
|
436 TInt CSenServiceManagerImpl::ExtractServiceDescriptionsL(TPtrC8& aSDs, |
|
437 RServiceDescriptionArray& aList) |
|
438 { |
|
439 TLSLOG_L(KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel,"CSenServiceManagerImpl::ExtractServiceDescriptionsL"); |
|
440 TInt retVal(KErrNotFound); |
|
441 |
|
442 |
|
443 if (aSDs.Length() > 0) |
|
444 { |
|
445 TPtrC8 single; |
|
446 TPtrC8 rest; |
|
447 _LIT8(KTab, "\t"); |
|
448 TBool loop(ETrue); |
|
449 TInt pos(-1); |
|
450 CSenXmlServiceDescription* desc = NULL; |
|
451 rest.Set(aSDs); |
|
452 |
|
453 while (loop) |
|
454 { |
|
455 pos = rest.Find(KTab()); |
|
456 if (pos > 0) |
|
457 { |
|
458 desc = CSenXmlServiceDescription::NewLC(); |
|
459 iReader->SetContentHandler(*desc); |
|
460 desc->SetReader(*iReader); |
|
461 single.Set(rest.Left(pos)); |
|
462 |
|
463 TInt leaveCode(KErrNone); |
|
464 TRAP(leaveCode, desc->ParseL(single)); |
|
465 if(leaveCode!=KErrNone) |
|
466 { |
|
467 TInt count(aList.Count()); |
|
468 TLSLOG_FORMAT((KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel , _L8("-desc->ParseL(#%d): parsing failed: %d"), count+1, leaveCode)); |
|
469 |
|
470 CleanupStack::PopAndDestroy(); // desc |
|
471 if(count == 0) |
|
472 { |
|
473 retVal = KErrNotFound; // could not parse single service description |
|
474 } |
|
475 |
|
476 break; |
|
477 } |
|
478 |
|
479 rest.Set(rest.Mid(pos+1)); // Check |
|
480 retVal = aList.Append(desc); |
|
481 if(retVal == KErrNone) |
|
482 { |
|
483 CleanupStack::Pop(); // desc |
|
484 } |
|
485 else |
|
486 { |
|
487 CleanupStack::PopAndDestroy(); |
|
488 } |
|
489 desc = NULL; |
|
490 } |
|
491 else |
|
492 { |
|
493 desc = CSenXmlServiceDescription::NewLC(); |
|
494 iReader->SetContentHandler(*desc); |
|
495 desc->SetReader(*iReader); |
|
496 |
|
497 TInt leaveCode(KErrNone); |
|
498 TRAP(leaveCode, desc->ParseL(rest)); |
|
499 if(leaveCode!=KErrNone) |
|
500 { |
|
501 TInt count(aList.Count()); |
|
502 TLSLOG_FORMAT((KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel , _L8("-desc->ParseL(#%d): parsing failed: %d"), count+1, leaveCode)); |
|
503 |
|
504 CleanupStack::PopAndDestroy(); // desc |
|
505 if(count == 0) |
|
506 { |
|
507 retVal = KErrNotFound; // could not parse single service description |
|
508 } |
|
509 |
|
510 break; |
|
511 } |
|
512 retVal = aList.Append(desc); |
|
513 if(retVal == KErrNone) |
|
514 { |
|
515 CleanupStack::Pop(); // desc |
|
516 } |
|
517 else |
|
518 { |
|
519 CleanupStack::PopAndDestroy(); |
|
520 } |
|
521 desc = NULL; |
|
522 break; |
|
523 } |
|
524 |
|
525 if (rest.Length() == 0 ) |
|
526 { |
|
527 break; |
|
528 } |
|
529 |
|
530 } |
|
531 } // END OF: if aSD.Length() > 0 |
|
532 return retVal; |
|
533 } |
|
534 |
|
535 TInt CSenServiceManagerImpl::ExtractCredentialsL(TPtrC8& aCredentials, |
|
536 RCredentialArray& aList, |
|
537 RCredentialPropertiesArray& aCredentialPropertiesList) |
|
538 { |
|
539 TLSLOG_L(KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel,"CSenServiceManagerImpl::ExtractCredentialsL"); |
|
540 TInt retVal(KErrNotFound); |
|
541 |
|
542 if ( aCredentials.Length() > 0 ) |
|
543 { |
|
544 TPtrC8 single; |
|
545 TPtrC8 rest; |
|
546 _LIT8(KTab, "\t"); |
|
547 _LIT8(KNewline, "\n"); |
|
548 _LIT8(KNoProperties, "-"); |
|
549 |
|
550 TInt pos(KErrNone); |
|
551 CSenCredential2* pCredential = NULL; |
|
552 rest.Set(aCredentials); |
|
553 CSenParser* pParser = CSenParser::NewLC(); |
|
554 |
|
555 while ( pos != KErrNotFound && rest.Length() > 0 ) |
|
556 { |
|
557 pos = rest.Find(KTab()); |
|
558 if (pos > 0) |
|
559 { |
|
560 single.Set(rest.Left(pos)); |
|
561 } |
|
562 else |
|
563 { |
|
564 single.Set(rest); |
|
565 } |
|
566 |
|
567 if ( single.Length() > 0 ) |
|
568 { |
|
569 pCredential = CSenCredential2::NewLC(); |
|
570 |
|
571 TInt leaveCode(KErrNone); |
|
572 TRAP(leaveCode, pParser->ParseL(single, *pCredential)); |
|
573 if ( leaveCode != KErrNone ) |
|
574 { |
|
575 TInt count(aList.Count()); |
|
576 TLSLOG_FORMAT((KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel , _L8("- Credential(#%d): parsing failed: %d"), count+1, leaveCode)); |
|
577 |
|
578 CleanupStack::PopAndDestroy(); // desc |
|
579 if ( count == 0 ) |
|
580 { |
|
581 retVal = KErrNotFound; // could not parse single credential |
|
582 } |
|
583 |
|
584 break; |
|
585 } |
|
586 |
|
587 retVal = aList.Append(pCredential); |
|
588 if(retVal == KErrNone) |
|
589 { |
|
590 CleanupStack::Pop(); // desc |
|
591 } |
|
592 else |
|
593 { |
|
594 CleanupStack::PopAndDestroy(); |
|
595 } |
|
596 |
|
597 rest.Set(rest.Mid(pos+1)); // Check |
|
598 |
|
599 pos = rest.Find(KNewline()); |
|
600 if (pos > 0) |
|
601 { |
|
602 single.Set(rest.Left(pos)); |
|
603 } |
|
604 else |
|
605 { |
|
606 single.Set(rest); |
|
607 } |
|
608 |
|
609 if ( single == KNoProperties ) |
|
610 { |
|
611 aCredentialPropertiesList.Append(NULL); |
|
612 } |
|
613 else |
|
614 { |
|
615 if ( single.Length() > 0 ) |
|
616 { |
|
617 CSenXmlProperties* pCredentialProperties = CSenXmlProperties::NewLC(); |
|
618 pCredentialProperties->SetReader(*iReader); |
|
619 leaveCode = KErrNone; |
|
620 TRAP(leaveCode, pCredentialProperties->ReadFromL(single)); |
|
621 if ( leaveCode != KErrNone ) |
|
622 { |
|
623 TInt count(aList.Count()); |
|
624 TLSLOG_FORMAT((KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel , _L8("- CredentialProperties(#%d): parsing failed: %d"), count+1, leaveCode)); |
|
625 |
|
626 CleanupStack::PopAndDestroy(pCredentialProperties); |
|
627 if ( count == 0 ) |
|
628 { |
|
629 retVal = KErrNotFound; // could not parse single credential |
|
630 } |
|
631 |
|
632 retVal = aCredentialPropertiesList.Append(NULL); |
|
633 break; |
|
634 } |
|
635 |
|
636 retVal = aCredentialPropertiesList.Append(pCredentialProperties); |
|
637 if(retVal == KErrNone) |
|
638 { |
|
639 CleanupStack::Pop(pCredentialProperties); |
|
640 } |
|
641 else |
|
642 { |
|
643 CleanupStack::PopAndDestroy(pCredentialProperties); |
|
644 } |
|
645 } |
|
646 else |
|
647 { |
|
648 aCredentialPropertiesList.Append(NULL); |
|
649 } |
|
650 } |
|
651 |
|
652 rest.Set(rest.Mid(pos+1)); // Check |
|
653 |
|
654 pCredential = NULL; |
|
655 } |
|
656 else |
|
657 { |
|
658 pos = KErrNotFound; |
|
659 } |
|
660 } |
|
661 |
|
662 CleanupStack::PopAndDestroy(pParser); |
|
663 } // END OF: if aCredentials.Length() > 0 |
|
664 return retVal; |
|
665 } |
|
666 |
|
667 TInt CSenServiceManagerImpl::CredentialsL(const TDesC8& aEndpoint, |
|
668 RCredentialArray& aCredentials, |
|
669 RCredentialPropertiesArray& aCredentialProperties) |
|
670 { |
|
671 TInt retVal(KErrNone); |
|
672 |
|
673 CSenXmlServiceDescription* pServDesc = CSenXmlServiceDescription::NewLC(); |
|
674 pServDesc->SetEndPointL(aEndpoint); |
|
675 |
|
676 retVal = CredentialsL(*pServDesc, aCredentials, aCredentialProperties); |
|
677 |
|
678 CleanupStack::PopAndDestroy(pServDesc); |
|
679 |
|
680 return retVal; |
|
681 } |
|
682 |
|
683 TInt CSenServiceManagerImpl::CredentialsL(const TDesC8& aEndpoint, |
|
684 const CSenIdentityProvider& aIdP, |
|
685 RCredentialArray& aCredentials, |
|
686 RCredentialPropertiesArray& aCredentialProperties) |
|
687 { |
|
688 TInt retVal(KErrNone); |
|
689 TPtrC8 credentials; |
|
690 |
|
691 CSenXmlServiceDescription* pServDesc = CSenXmlServiceDescription::NewLC(); |
|
692 pServDesc->SetEndPointL(aEndpoint); |
|
693 HBufC8* pPatternAsXml = pServDesc->AsXmlL(); |
|
694 CleanupStack::PopAndDestroy(pServDesc); |
|
695 CleanupStack::PushL(pPatternAsXml); |
|
696 if( &aIdP == NULL ) |
|
697 { |
|
698 return KErrArgument; |
|
699 } |
|
700 |
|
701 HBufC8* pIdPAsXml = ((CSenIdentityProvider&)aIdP).AsXmlL(); |
|
702 CleanupStack::PushL(pIdPAsXml); |
|
703 |
|
704 CSenChunk* pSenChunk = CSenChunk::NewLC(NextChunkNameL()); //Codescannerwarnings |
|
705 //pSenChunk->SetLogger(Log()); |
|
706 retVal = pSenChunk->CreateChunk(); |
|
707 if (retVal == KErrNone) |
|
708 { |
|
709 retVal = pSenChunk->DescsToChunk(*pPatternAsXml, *pIdPAsXml); |
|
710 if (retVal == KErrNone) |
|
711 { |
|
712 retVal = iConnection.CredentialsL(*pSenChunk); |
|
713 if (retVal == KErrNone) |
|
714 { |
|
715 retVal = pSenChunk->DescFromChunk(credentials); |
|
716 if(retVal == KErrNone) |
|
717 { |
|
718 retVal = ExtractCredentialsL(credentials, aCredentials, aCredentialProperties); |
|
719 } |
|
720 } |
|
721 } |
|
722 } |
|
723 CleanupStack::PopAndDestroy(pSenChunk); |
|
724 |
|
725 CleanupStack::PopAndDestroy(pIdPAsXml); |
|
726 CleanupStack::PopAndDestroy(pPatternAsXml); |
|
727 |
|
728 return retVal; |
|
729 } |
|
730 |
|
731 TInt CSenServiceManagerImpl::CredentialsL(const TDesC8& aEndpoint, |
|
732 const TDesC8& aUserName, |
|
733 const TDesC8& aPassword, |
|
734 RCredentialArray& aCredentials, |
|
735 RCredentialPropertiesArray& aCredentialProperties) |
|
736 { |
|
737 TInt retVal(KErrNone); |
|
738 TPtrC8 credentials; |
|
739 |
|
740 CSenXmlServiceDescription* pServDesc = CSenXmlServiceDescription::NewLC(); |
|
741 pServDesc->SetEndPointL(aEndpoint); |
|
742 HBufC8* pPatternAsXml = pServDesc->AsXmlL(); |
|
743 CleanupStack::PopAndDestroy(pServDesc); |
|
744 CleanupStack::PushL(pPatternAsXml); |
|
745 |
|
746 CSenIdentityProvider* pIdP = CSenIdentityProvider::NewLC(KIdentityProviderName); |
|
747 pIdP->SetUserInfoL(aUserName, aUserName, aPassword); |
|
748 HBufC8* pIdPAsXml = pIdP->AsXmlL(); |
|
749 CleanupStack::PopAndDestroy(pIdP); |
|
750 CleanupStack::PushL(pIdPAsXml); |
|
751 |
|
752 CSenChunk* pSenChunk = CSenChunk::NewLC(NextChunkNameL()); //Codescannerwarnings |
|
753 //pSenChunk->SetLogger(Log()); |
|
754 retVal = pSenChunk->CreateChunk(); |
|
755 if (retVal == KErrNone) |
|
756 { |
|
757 retVal = pSenChunk->DescsToChunk(*pPatternAsXml, *pIdPAsXml); |
|
758 if (retVal == KErrNone) |
|
759 { |
|
760 retVal = iConnection.CredentialsL(*pSenChunk); |
|
761 if (retVal == KErrNone) |
|
762 { |
|
763 retVal = pSenChunk->DescFromChunk(credentials); |
|
764 if(retVal == KErrNone) |
|
765 { |
|
766 retVal = ExtractCredentialsL(credentials, aCredentials, aCredentialProperties); |
|
767 } |
|
768 } |
|
769 } |
|
770 } |
|
771 CleanupStack::PopAndDestroy(pSenChunk); |
|
772 |
|
773 CleanupStack::PopAndDestroy(pIdPAsXml); |
|
774 CleanupStack::PopAndDestroy(pPatternAsXml); |
|
775 |
|
776 return retVal; |
|
777 } |
|
778 |
|
779 TInt CSenServiceManagerImpl::CredentialsL(const MSenServiceDescription& aPattern, |
|
780 RCredentialArray& aCredentials, |
|
781 RCredentialPropertiesArray& aCredentialProperties) |
|
782 { |
|
783 TInt retVal(KErrNone); |
|
784 TPtrC8 credentials; |
|
785 |
|
786 if(&aPattern == NULL) |
|
787 { |
|
788 return KErrArgument; |
|
789 } |
|
790 HBufC8* pPatternAsXml = ((MSenServiceDescription&)aPattern).AsXmlL(); |
|
791 CleanupStack::PushL(pPatternAsXml); |
|
792 |
|
793 CSenChunk* pSenChunk = CSenChunk::NewLC(NextChunkNameL()); //Codescannerwarnings |
|
794 //pSenChunk->SetLogger(Log()); |
|
795 retVal = pSenChunk->CreateChunk(); |
|
796 if (retVal == KErrNone) |
|
797 { |
|
798 retVal = pSenChunk->DescsToChunk(*pPatternAsXml, KNullDesC8); |
|
799 if (retVal == KErrNone) |
|
800 { |
|
801 retVal = iConnection.CredentialsL(*pSenChunk); |
|
802 if (retVal == KErrNone) |
|
803 { |
|
804 retVal = pSenChunk->DescFromChunk(credentials); |
|
805 if(retVal == KErrNone) |
|
806 { |
|
807 retVal = ExtractCredentialsL(credentials, aCredentials, aCredentialProperties); |
|
808 } |
|
809 } |
|
810 else if ( retVal == KErrSenNoPermission ) |
|
811 { |
|
812 if ( ipAuthProvider ) |
|
813 { |
|
814 TBool identityProviderCreated = EFalse; |
|
815 CSenIdentityProvider* pIdP = NULL; |
|
816 pIdP = (CSenIdentityProvider*)ipAuthProvider->IdentityProviderL(); |
|
817 if ( !pIdP ) |
|
818 { |
|
819 const TPtrC8 userName = ipAuthProvider->UsernameL(); |
|
820 const TPtrC8 password = ipAuthProvider->PasswordL(); |
|
821 if ( userName != KNullDesC8 && |
|
822 password != KNullDesC8 ) |
|
823 { |
|
824 pIdP = CSenIdentityProvider::NewLC(KIdentityProviderName); |
|
825 pIdP->SetUserInfoL( userName , |
|
826 userName , |
|
827 password ); |
|
828 identityProviderCreated = ETrue; |
|
829 } |
|
830 } |
|
831 |
|
832 if ( pIdP ) |
|
833 { |
|
834 HBufC8* pIdPAsXml = pIdP->AsXmlL(); |
|
835 CleanupStack::PushL(pIdPAsXml); |
|
836 |
|
837 retVal = pSenChunk->DescsToChunk(*pPatternAsXml, *pIdPAsXml); |
|
838 if (retVal == KErrNone) |
|
839 { |
|
840 retVal = iConnection.CredentialsL(*pSenChunk); |
|
841 if (retVal == KErrNone) |
|
842 { |
|
843 retVal = pSenChunk->DescFromChunk(credentials); |
|
844 if(retVal == KErrNone) |
|
845 { |
|
846 retVal = ExtractCredentialsL(credentials, aCredentials, aCredentialProperties); |
|
847 } |
|
848 } |
|
849 } |
|
850 CleanupStack::PopAndDestroy(pIdPAsXml); |
|
851 if ( identityProviderCreated ) |
|
852 { |
|
853 CleanupStack::PopAndDestroy(pIdP); |
|
854 } |
|
855 //CleanupStack::PopAndDestroy(pIdPAsXml); |
|
856 } |
|
857 } |
|
858 } |
|
859 } |
|
860 } |
|
861 CleanupStack::PopAndDestroy(pSenChunk); |
|
862 |
|
863 CleanupStack::PopAndDestroy(pPatternAsXml); |
|
864 |
|
865 return retVal; |
|
866 } |
|
867 |
|
868 TInt CSenServiceManagerImpl::CredentialsL(const MSenServiceDescription& aPattern, |
|
869 const CSenIdentityProvider& aIdP, |
|
870 RCredentialArray& aCredentials, |
|
871 RCredentialPropertiesArray& aCredentialProperties) |
|
872 { |
|
873 TInt retVal(KErrNone); |
|
874 TPtrC8 credentials; |
|
875 |
|
876 if(&aPattern == NULL || &aIdP == NULL) |
|
877 { |
|
878 return KErrArgument; |
|
879 } |
|
880 HBufC8* pPatternAsXml = ((MSenServiceDescription&)aPattern).AsXmlL(); |
|
881 CleanupStack::PushL(pPatternAsXml); |
|
882 |
|
883 HBufC8* pIdPAsXml = ((CSenIdentityProvider&)aIdP).AsXmlL(); |
|
884 CleanupStack::PushL(pIdPAsXml); |
|
885 |
|
886 CSenChunk* pSenChunk = CSenChunk::NewLC(NextChunkNameL()); //Codescannerwarnings |
|
887 //pSenChunk->SetLogger(Log()); |
|
888 retVal = pSenChunk->CreateChunk(); |
|
889 if (retVal == KErrNone) |
|
890 { |
|
891 retVal = pSenChunk->DescsToChunk(*pPatternAsXml, *pIdPAsXml); |
|
892 if (retVal == KErrNone) |
|
893 { |
|
894 retVal = iConnection.CredentialsL(*pSenChunk); |
|
895 if (retVal == KErrNone) |
|
896 { |
|
897 retVal = pSenChunk->DescFromChunk(credentials); |
|
898 if(retVal == KErrNone) |
|
899 { |
|
900 retVal = ExtractCredentialsL(credentials, aCredentials, aCredentialProperties); |
|
901 } |
|
902 } |
|
903 } |
|
904 } |
|
905 CleanupStack::PopAndDestroy(pSenChunk); |
|
906 |
|
907 CleanupStack::PopAndDestroy(pIdPAsXml); |
|
908 CleanupStack::PopAndDestroy(pPatternAsXml); |
|
909 |
|
910 return retVal; |
|
911 } |
|
912 |
|
913 TInt CSenServiceManagerImpl::CredentialsL(const MSenServiceDescription& aPattern, |
|
914 const TDesC8& aUserName, |
|
915 const TDesC8& aPassword, |
|
916 RCredentialArray& aCredentials, |
|
917 RCredentialPropertiesArray& aCredentialProperties) |
|
918 { |
|
919 TInt retVal(KErrNone); |
|
920 TPtrC8 credentials; |
|
921 |
|
922 if(&aPattern == NULL) |
|
923 { |
|
924 return KErrArgument; |
|
925 } |
|
926 HBufC8* pPatternAsXml = ((MSenServiceDescription&)aPattern).AsXmlL(); |
|
927 CleanupStack::PushL(pPatternAsXml); |
|
928 |
|
929 CSenIdentityProvider* pIdP = CSenIdentityProvider::NewLC(KIdentityProviderName); |
|
930 pIdP->SetUserInfoL(aUserName, aUserName, aPassword); |
|
931 HBufC8* pIdPAsXml = pIdP->AsXmlL(); |
|
932 CleanupStack::PopAndDestroy(pIdP); |
|
933 CleanupStack::PushL(pIdPAsXml); |
|
934 |
|
935 CSenChunk* pSenChunk = CSenChunk::NewLC(NextChunkNameL()); //Codescannerwarnings |
|
936 //pSenChunk->SetLogger(Log()); |
|
937 retVal = pSenChunk->CreateChunk(); |
|
938 if (retVal == KErrNone) |
|
939 { |
|
940 retVal = pSenChunk->DescsToChunk(*pPatternAsXml, *pIdPAsXml); |
|
941 if (retVal == KErrNone) |
|
942 { |
|
943 retVal = iConnection.CredentialsL(*pSenChunk); |
|
944 if (retVal == KErrNone) |
|
945 { |
|
946 retVal = pSenChunk->DescFromChunk(credentials); |
|
947 if(retVal == KErrNone) |
|
948 { |
|
949 retVal = ExtractCredentialsL(credentials, aCredentials, aCredentialProperties); |
|
950 } |
|
951 } |
|
952 } |
|
953 } |
|
954 CleanupStack::PopAndDestroy(pSenChunk); |
|
955 |
|
956 CleanupStack::PopAndDestroy(pIdPAsXml); |
|
957 CleanupStack::PopAndDestroy(pPatternAsXml); |
|
958 |
|
959 return retVal; |
|
960 } |
|
961 |
|
962 TInt CSenServiceManagerImpl::AddCredentialL(const MSenServiceDescription& aPattern, |
|
963 const CSenIdentityProvider& aIdP, |
|
964 const CSenCredential2& aCredential) |
|
965 { |
|
966 TInt retVal(KErrNone); |
|
967 |
|
968 if(&aPattern == NULL || &aIdP == NULL || &aCredential== NULL) |
|
969 { |
|
970 return KErrArgument; |
|
971 } |
|
972 HBufC8* pPatternAsXml = ((MSenServiceDescription&)aPattern).AsXmlL(); |
|
973 CleanupStack::PushL(pPatternAsXml); |
|
974 |
|
975 HBufC8* pIdPAsXml = ((CSenIdentityProvider&)aIdP).AsXmlL(); |
|
976 CleanupStack::PushL(pIdPAsXml); |
|
977 |
|
978 HBufC8* pCredentialAsXml = ((CSenCredential2&)aCredential).AsXmlL(); |
|
979 CleanupStack::PushL(pCredentialAsXml); |
|
980 |
|
981 CSenChunk* pSenChunk = CSenChunk::NewLC(NextChunkNameL()); //Codescannerwarnings |
|
982 //pSenChunk->SetLogger(Log()); |
|
983 retVal = pSenChunk->CreateChunk(); |
|
984 |
|
985 if (retVal == KErrNone) |
|
986 { |
|
987 retVal = pSenChunk->DescsToChunk(*pPatternAsXml, *pIdPAsXml); |
|
988 retVal = pSenChunk->DescToChunk(*pCredentialAsXml, 2); |
|
989 if (retVal == KErrNone) |
|
990 { |
|
991 retVal = iConnection.AddCredentialL(*pSenChunk); |
|
992 } |
|
993 } |
|
994 CleanupStack::PopAndDestroy(pSenChunk); |
|
995 |
|
996 CleanupStack::PopAndDestroy(pCredentialAsXml); |
|
997 CleanupStack::PopAndDestroy(pIdPAsXml); |
|
998 CleanupStack::PopAndDestroy(pPatternAsXml); |
|
999 |
|
1000 return retVal; |
|
1001 } |
|
1002 |
|
1003 TInt CSenServiceManagerImpl::AddCredentialL(const TDesC8& aEndpoint, |
|
1004 const CSenIdentityProvider& aIdP, |
|
1005 const CSenCredential2& aCredential) |
|
1006 { |
|
1007 CSenXmlServiceDescription* pServDesc = CSenXmlServiceDescription::NewLC(); |
|
1008 pServDesc->SetEndPointL(aEndpoint); |
|
1009 |
|
1010 TInt retVal = AddCredentialL(*pServDesc, aIdP, aCredential); |
|
1011 |
|
1012 CleanupStack::PopAndDestroy(pServDesc); |
|
1013 |
|
1014 return retVal; |
|
1015 } |
|
1016 |
|
1017 TInt CSenServiceManagerImpl::AddCredentialL(const MSenServiceDescription& aPattern, |
|
1018 const CSenIdentityProvider& aIdP, |
|
1019 const CSenCredential2& aCredential, |
|
1020 const CSenXmlProperties& aCredentialProperties) |
|
1021 { |
|
1022 TInt retVal(KErrNone); |
|
1023 |
|
1024 if(&aPattern == NULL || &aIdP == NULL || &aCredential== NULL || &aCredentialProperties == NULL ) |
|
1025 { |
|
1026 return KErrArgument; |
|
1027 } |
|
1028 HBufC8* pPatternAsXml = ((MSenServiceDescription&)aPattern).AsXmlL(); |
|
1029 CleanupStack::PushL(pPatternAsXml); |
|
1030 |
|
1031 HBufC8* pIdPAsXml = ((CSenIdentityProvider&)aIdP).AsXmlL(); |
|
1032 CleanupStack::PushL(pIdPAsXml); |
|
1033 |
|
1034 HBufC8* pCredentialAsXml = ((CSenCredential2&)aCredential).AsXmlL(); |
|
1035 CleanupStack::PushL(pCredentialAsXml); |
|
1036 |
|
1037 HBufC8* pCredentialPropertiesAsXml = ((CSenXmlProperties&)aCredentialProperties).AsUtf8L(); |
|
1038 CleanupStack::PushL(pCredentialPropertiesAsXml); |
|
1039 |
|
1040 CSenChunk* pSenChunk = CSenChunk::NewLC(NextChunkNameL()); //Codescannerwarnings |
|
1041 //pSenChunk->SetLogger(Log()); |
|
1042 retVal = pSenChunk->CreateChunk(); |
|
1043 |
|
1044 if (retVal == KErrNone) |
|
1045 { |
|
1046 retVal = pSenChunk->DescsToChunk(*pPatternAsXml, *pIdPAsXml); |
|
1047 retVal = pSenChunk->DescToChunk(*pCredentialAsXml, 2); |
|
1048 retVal = pSenChunk->DescToChunk(*pCredentialPropertiesAsXml, 3); |
|
1049 if (retVal == KErrNone) |
|
1050 { |
|
1051 retVal = iConnection.AddCredentialL(*pSenChunk); |
|
1052 } |
|
1053 } |
|
1054 CleanupStack::PopAndDestroy(pSenChunk); |
|
1055 |
|
1056 |
|
1057 CleanupStack::PopAndDestroy(pCredentialPropertiesAsXml); |
|
1058 CleanupStack::PopAndDestroy(pCredentialAsXml); |
|
1059 CleanupStack::PopAndDestroy(pIdPAsXml); |
|
1060 CleanupStack::PopAndDestroy(pPatternAsXml); |
|
1061 |
|
1062 return retVal; |
|
1063 } |
|
1064 |
|
1065 TInt CSenServiceManagerImpl::AddCredentialL(const TDesC8& aEndpoint, |
|
1066 const CSenIdentityProvider& aIdP, |
|
1067 const CSenCredential2& aCredential, |
|
1068 const CSenXmlProperties& aCredentialProperties) |
|
1069 { |
|
1070 CSenXmlServiceDescription* pServDesc = CSenXmlServiceDescription::NewLC(); |
|
1071 pServDesc->SetEndPointL(aEndpoint); |
|
1072 |
|
1073 TInt retVal = AddCredentialL(*pServDesc, aIdP, aCredential, aCredentialProperties); |
|
1074 |
|
1075 CleanupStack::PopAndDestroy(pServDesc); |
|
1076 |
|
1077 return retVal; |
|
1078 } |
|
1079 |
|
1080 TInt CSenServiceManagerImpl::RemoveCredentialsL(const CSenIdentityProvider& aIdP) |
|
1081 { |
|
1082 TInt retVal(KErrNone); |
|
1083 |
|
1084 if(&aIdP == NULL) |
|
1085 { |
|
1086 return KErrArgument; |
|
1087 } |
|
1088 |
|
1089 HBufC8* pIdPAsXml = ((CSenIdentityProvider&)aIdP).AsXmlL(); |
|
1090 CleanupStack::PushL(pIdPAsXml); |
|
1091 |
|
1092 CSenChunk* pSenChunk = CSenChunk::NewLC(NextChunkNameL()); //Codescannerwarnings |
|
1093 retVal = pSenChunk->CreateChunk(); |
|
1094 |
|
1095 if (retVal == KErrNone) |
|
1096 { |
|
1097 retVal = pSenChunk->DescsToChunk(KNullDesC8(), *pIdPAsXml); |
|
1098 if (retVal == KErrNone) |
|
1099 { |
|
1100 retVal = iConnection.RemoveCredentialsL(*pSenChunk); |
|
1101 } |
|
1102 } |
|
1103 CleanupStack::PopAndDestroy(pSenChunk); |
|
1104 |
|
1105 CleanupStack::PopAndDestroy(pIdPAsXml); |
|
1106 |
|
1107 return retVal; |
|
1108 |
|
1109 } |
|
1110 TInt CSenServiceManagerImpl::RemoveCredentialsL(const MSenServiceDescription& aPattern, |
|
1111 const CSenIdentityProvider& aIdP) |
|
1112 { |
|
1113 TInt retVal(KErrNone); |
|
1114 |
|
1115 if(&aPattern == NULL || &aIdP == NULL) |
|
1116 { |
|
1117 return KErrArgument; |
|
1118 } |
|
1119 HBufC8* pPatternAsXml = ((MSenServiceDescription&)aPattern).AsXmlL(); |
|
1120 CleanupStack::PushL(pPatternAsXml); |
|
1121 |
|
1122 HBufC8* pIdPAsXml = ((CSenIdentityProvider&)aIdP).AsXmlL(); |
|
1123 CleanupStack::PushL(pIdPAsXml); |
|
1124 |
|
1125 CSenChunk* pSenChunk = CSenChunk::NewLC(NextChunkNameL()); //Codescannerwarnings |
|
1126 //pSenChunk->SetLogger(Log()); |
|
1127 retVal = pSenChunk->CreateChunk(); |
|
1128 |
|
1129 if (retVal == KErrNone) |
|
1130 { |
|
1131 retVal = pSenChunk->DescsToChunk(*pPatternAsXml, *pIdPAsXml); |
|
1132 if (retVal == KErrNone) |
|
1133 { |
|
1134 retVal = iConnection.RemoveCredentialsL(*pSenChunk); |
|
1135 } |
|
1136 } |
|
1137 CleanupStack::PopAndDestroy(pSenChunk); |
|
1138 |
|
1139 CleanupStack::PopAndDestroy(pIdPAsXml); |
|
1140 CleanupStack::PopAndDestroy(pPatternAsXml); |
|
1141 |
|
1142 return retVal; |
|
1143 } |
|
1144 |
|
1145 TInt CSenServiceManagerImpl::RemoveCredentialsL(const MSenServiceDescription& aPattern, |
|
1146 const TDesC8& aUserName, |
|
1147 const TDesC8& aPassword) |
|
1148 { |
|
1149 CSenIdentityProvider* pIdP = CSenIdentityProvider::NewLC(KIdentityProviderName); |
|
1150 pIdP->SetUserInfoL(aUserName, aUserName, aPassword); |
|
1151 |
|
1152 TInt retVal = RemoveCredentialsL(aPattern, *pIdP); |
|
1153 |
|
1154 CleanupStack::PopAndDestroy(pIdP); |
|
1155 |
|
1156 return retVal; |
|
1157 } |
|
1158 |
|
1159 |
|
1160 TInt CSenServiceManagerImpl::IdentityProvidersL( RIdentityProviderArray& aList ) |
|
1161 { |
|
1162 TInt retVal(KErrNone); |
|
1163 TPtrC8 descriptions; |
|
1164 |
|
1165 CSenChunk* pSenChunk = CSenChunk::NewLC(NextChunkNameL()); |
|
1166 retVal = pSenChunk->CreateChunk(); |
|
1167 if (retVal == KErrNone) |
|
1168 { |
|
1169 retVal = iConnection.IdentityProvidersL(*pSenChunk); |
|
1170 if (retVal == KErrNone) |
|
1171 { |
|
1172 retVal = pSenChunk->DescFromChunk(descriptions); |
|
1173 if(retVal == KErrNone) |
|
1174 { |
|
1175 retVal = ExtractIdentiyProvidersL(descriptions, aList); |
|
1176 } |
|
1177 } |
|
1178 } |
|
1179 CleanupStack::PopAndDestroy(pSenChunk); // Close chunk |
|
1180 return retVal; |
|
1181 } |
|
1182 TInt CSenServiceManagerImpl::ExtractIdentiyProvidersL(TPtrC8& aIdPs, |
|
1183 RIdentityProviderArray& aList) |
|
1184 { |
|
1185 TLSLOG_L(KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel,"CSenServiceManagerImpl::ExtractIdentiyProvidersL"); |
|
1186 TInt retVal(KErrNotFound); |
|
1187 |
|
1188 |
|
1189 if (aIdPs.Length() > 0) |
|
1190 { |
|
1191 TPtrC8 single; |
|
1192 TPtrC8 rest; |
|
1193 _LIT8(KTab, "\t"); |
|
1194 TBool loop(ETrue); |
|
1195 TInt pos(-1); |
|
1196 CSenIdentityProvider* idp = NULL; |
|
1197 rest.Set(aIdPs); |
|
1198 |
|
1199 while (loop) |
|
1200 { |
|
1201 pos = rest.Find(KTab()); |
|
1202 if (pos > 0) |
|
1203 { |
|
1204 idp = CSenIdentityProvider::NewLC(KNullDesC8); |
|
1205 iReader->SetContentHandler(*idp); |
|
1206 idp->SetReader(*iReader); |
|
1207 single.Set(rest.Left(pos)); |
|
1208 |
|
1209 TInt leaveCode(KErrNone); |
|
1210 TLSLOG_ALL(KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel, single); |
|
1211 TRAP(leaveCode, idp->ParseL(single)); |
|
1212 if(leaveCode!=KErrNone) |
|
1213 { |
|
1214 TInt count(aList.Count()); |
|
1215 TLSLOG_FORMAT((KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel , _L8("-idp->ParseL(#%d): parsing failed: %d"), count+1, leaveCode)); |
|
1216 |
|
1217 CleanupStack::PopAndDestroy(); // desc |
|
1218 if(count == 0) |
|
1219 { |
|
1220 retVal = KErrNotFound; // could not parse single service description |
|
1221 } |
|
1222 |
|
1223 break; |
|
1224 } |
|
1225 |
|
1226 rest.Set(rest.Mid(pos+1)); // Check |
|
1227 retVal = aList.Append(idp); |
|
1228 if(retVal == KErrNone) |
|
1229 { |
|
1230 CleanupStack::Pop(); // desc |
|
1231 } |
|
1232 else |
|
1233 { |
|
1234 CleanupStack::PopAndDestroy(); |
|
1235 } |
|
1236 idp = NULL; |
|
1237 } |
|
1238 else |
|
1239 { |
|
1240 idp = CSenIdentityProvider::NewLC(KNullDesC8); |
|
1241 iReader->SetContentHandler(*idp); |
|
1242 idp->SetReader(*iReader); |
|
1243 |
|
1244 TInt leaveCode(KErrNone); |
|
1245 TRAP(leaveCode, idp->ParseL(rest)); |
|
1246 if(leaveCode!=KErrNone) |
|
1247 { |
|
1248 TInt count(aList.Count()); |
|
1249 TLSLOG_FORMAT((KSenServiceManagerLogChannelBase+iConnectionID, KMinLogLevel , _L8("-idp->ParseL(#%d): parsing failed: %d"), count+1, leaveCode)); |
|
1250 |
|
1251 CleanupStack::PopAndDestroy(); // desc |
|
1252 if(count == 0) |
|
1253 { |
|
1254 retVal = KErrNotFound; // could not parse single service description |
|
1255 } |
|
1256 |
|
1257 break; |
|
1258 } |
|
1259 retVal = aList.Append(idp); |
|
1260 if(retVal == KErrNone) |
|
1261 { |
|
1262 CleanupStack::Pop(); // desc |
|
1263 } |
|
1264 else |
|
1265 { |
|
1266 CleanupStack::PopAndDestroy(); |
|
1267 } |
|
1268 idp = NULL; |
|
1269 break; |
|
1270 } |
|
1271 |
|
1272 if (rest.Length() == 0 ) |
|
1273 { |
|
1274 break; |
|
1275 } |
|
1276 |
|
1277 } |
|
1278 } // END OF: if idp.Length() > 0 |
|
1279 return retVal; |
|
1280 } |
|
1281 TAny* CSenServiceManagerImpl::InterfaceByUid( TUid aUID ) |
|
1282 { |
|
1283 if ( aUID == KSenInterfaceUidInternalServiceManager ) |
|
1284 { |
|
1285 TLSLOG_FORMAT(( KSenServiceConnectionLogChannelBase+iConnectionID, KMinLogLevel , _L8("CSenServiceConnectionImpl::InterfaceByUid(%d) == KSenInterfaceUidInternalServiceManager" ), aUID.iUid )); |
|
1286 // Must be cast to M-class (as the same C-class implements multiple M-classes): |
|
1287 MSenInternalServiceManager* manager = (MSenInternalServiceManager*) this; |
|
1288 return manager; |
|
1289 } |
|
1290 return NULL; |
|
1291 } |
|
1292 |
|
1293 // END OF FILE |