114 CLOG( ( EClientConnect, 0, _L( "<- RCookieManager::Connect" ) ) ); |
115 CLOG( ( EClientConnect, 0, _L( "<- RCookieManager::Connect" ) ) ); |
115 return error; |
116 return error; |
116 } |
117 } |
117 |
118 |
118 // --------------------------------------------------------- |
119 // --------------------------------------------------------- |
119 // RCookieManager::GetCookies |
120 // RCookieManager::DoGetCookies |
120 // --------------------------------------------------------- |
121 // --------------------------------------------------------- |
121 // |
122 // |
122 TInt RCookieManager::DoGetCookies( TDes8& aBuffer ) const |
123 TInt RCookieManager::DoGetCookies( TDes8& aBuffer ) const |
123 { |
124 { |
124 return SendReceive( EGetCookies, TIpcArgs( &aBuffer ) ); |
125 return SendReceive( EGetCookies, TIpcArgs( &aBuffer ) ); |
125 } |
126 } |
126 |
127 |
127 // --------------------------------------------------------- |
128 // --------------------------------------------------------- |
128 // RCookieManager::GetCookieSize |
129 // RCookieManager::GetCookieSharableFlagFromServer |
|
130 // --------------------------------------------------------- |
|
131 // |
|
132 TInt RCookieManager::GetCookieSharableFlagFromServer(TBool& aCookieSharableFlag )const |
|
133 { |
|
134 TPckg<TBool> cookieSharableFlag(aCookieSharableFlag); |
|
135 return SendReceive( EGetCookieSharableFlag, TIpcArgs( &cookieSharableFlag ) ); |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------- |
|
139 // RCookieManager::DoGetCookieSize |
129 // --------------------------------------------------------- |
140 // --------------------------------------------------------- |
130 // |
141 // |
131 TInt RCookieManager::DoGetCookieSize( const TDesC8& aRequestUri, |
142 TInt RCookieManager::DoGetCookieSize( const TDesC8& aRequestUri, |
132 TPckg<TInt>& aPkgSize ) const |
143 TPckg<TInt>& aPkgSize,TDesC& aAppuidPtr ) const |
133 { |
144 { |
134 return SendReceive( EGetCookieSize, TIpcArgs( aRequestUri.Length(), |
145 return SendReceive( EGetCookieSize, TIpcArgs( &aAppuidPtr,aRequestUri.Length(), |
135 &aRequestUri, &aPkgSize ) ); |
146 &aRequestUri, &aPkgSize ) ); |
136 } |
147 } |
|
148 // --------------------------------------------------------- |
|
149 // RCookieManager::DestroyCookiesFromMemory |
|
150 // --------------------------------------------------------- |
|
151 // |
|
152 TInt RCookieManager::DestroyCookiesFromMemory( TInt& aDeleteStatus ) |
|
153 { |
|
154 CLOG(( EClient, 0, _L("-> RCookieManager::DestroyCookies") )); |
|
155 |
|
156 TPckg<TInt> pkgStatus( aDeleteStatus ); |
|
157 TInt ret = SendReceive( EDestroyCookies, TIpcArgs( &pkgStatus ) ) ; |
|
158 |
|
159 CLOG(( EClient, 0, |
|
160 _L("<- RCookieManager::DestroyCookies cleared %d cookies, errcode%d"), |
|
161 aDeleteStatus, ret ) ); |
|
162 |
|
163 return ret; |
|
164 |
|
165 } |
137 |
166 |
138 // --------------------------------------------------------- |
167 // --------------------------------------------------------- |
139 // RCookieManager::DoStoreCookie |
168 // RCookieManager::DoStoreCookie |
140 // --------------------------------------------------------- |
169 // --------------------------------------------------------- |
141 // |
170 // |
142 TInt RCookieManager::DoStoreCookie( const TDesC8& aPackedCookie, |
171 TInt RCookieManager::DoStoreCookie( const TDesC8& aPackedCookie, |
143 const TDesC8& aUri ) const |
172 const TDesC8& aUri,TDesC& aAppUidPtr ) const |
144 { |
173 { |
145 return SendReceive( EStoreCookie, TIpcArgs( aPackedCookie.Length(), |
174 return SendReceive( EStoreCookie, TIpcArgs( aPackedCookie.Length(), |
146 &aPackedCookie, aUri.Length(), &aUri ) ); |
175 &aPackedCookie, &aUri,&aAppUidPtr ) ); |
147 } |
176 } |
148 |
177 |
149 // --------------------------------------------------------- |
178 // --------------------------------------------------------- |
150 // RCookieManager::GetCookiesL |
179 // RCookieManager::GetCookiesL |
151 // --------------------------------------------------------- |
180 // --------------------------------------------------------- |
251 KCookieServerMinorVersionNumber, |
304 KCookieServerMinorVersionNumber, |
252 KCookieServerBuildVersionNumber )); |
305 KCookieServerBuildVersionNumber )); |
253 } |
306 } |
254 |
307 |
255 // --------------------------------------------------------- |
308 // --------------------------------------------------------- |
256 // RCookieManager::SetAppUidL |
309 // RCookieManager::SetAppUidL This method is no longer being |
|
310 // used in CookieFilter.As this method is exported so in order |
|
311 // to provide backward compatibilty this API implementation is changed |
257 // --------------------------------------------------------- |
312 // --------------------------------------------------------- |
258 // |
313 // |
259 EXPORT_C TInt RCookieManager::SetAppUidL( const TUint32& aAppUid ) |
314 EXPORT_C TInt RCookieManager::SetAppUidL( const TUint32& aAppUid ) |
260 { |
315 { |
261 CLOG(( EClient, 0, _L("->RCookieManager::SetAppUid") )); |
316 CLOG(( EClient, 0, _L("->RCookieManager::SetAppUid") )); |
262 HBufC* buf = HBufC::NewLC(128); |
317 TUint32 groupid = RProcess().SecureId().iId; |
|
318 CCookieClientData* cookieclientdata = CCookieClientDataArray::GetInstance()->Find(groupid, const_cast<TUint32&> (aAppUid)); |
|
319 if(cookieclientdata) |
|
320 { |
|
321 cookieclientdata->SetWidgetUid(aAppUid); |
|
322 } |
|
323 else |
|
324 { |
|
325 TBool cookieSharableFlag(EFalse); |
|
326 TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag); |
|
327 CCookieClientData* cookieclientdata = CCookieClientData::NewL(groupid, aAppUid, cookieSharableFlag,ETrue); |
|
328 cookieclientdata->SetInitFlag(ETrue); |
|
329 CCookieClientDataArray::GetInstance()->AddClientGroupDataL(cookieclientdata); |
|
330 } |
|
331 //Appuid value only takes 8 chars |
|
332 HBufC* buf = HBufC::NewLC(8); |
263 TPtr ptr(buf->Des()); |
333 TPtr ptr(buf->Des()); |
264 ptr.AppendNum(aAppUid,EHex); |
334 ptr.AppendNum(aAppUid,EHex); |
265 TInt error = SendReceive(ESetAppUid,TIpcArgs(ptr.Length(),&ptr)); |
335 TInt error = SendReceive(ESetAppUid,TIpcArgs(ptr.Length(),&ptr)); |
266 CleanupStack::PopAndDestroy(); |
336 CleanupStack::PopAndDestroy(); |
267 CLOG(( EClient, 0, _L("<-RCookieManager::SetAppUid") )); |
337 CLOG(( EClient, 0, _L("<-RCookieManager::SetAppUid") )); |
268 return error; |
338 return error; |
269 } |
339 } |
|
340 // --------------------------------------------------------- |
|
341 // RCookieManager::Close |
|
342 // --------------------------------------------------------- |
|
343 // |
|
344 |
|
345 EXPORT_C void RCookieManager::Close() |
|
346 { |
|
347 CLOG(( EClient, 0, _L("-> RCookieManager::Close") )); |
|
348 CCookieClientDataArray::GetInstance()->DeRef(); |
|
349 TInt deletestatus =0; |
|
350 DestroyCookiesFromMemory(deletestatus); |
|
351 CLOG(( EClient, 0, _L("-> RCookieManager::Close deletestatus = %d"), deletestatus )); |
|
352 RSessionBase::Close(); |
|
353 CLOG(( EClient, 0, _L("<- RCookieManager::Close") )); |
|
354 } |
|
355 // --------------------------------------------------------- |
|
356 // RCookieManager::StoreCookie Newly Added |
|
357 // --------------------------------------------------------- |
|
358 // |
|
359 EXPORT_C TInt RCookieManager::StoreCookie( const CCookie& aCookie, |
|
360 const TUriC8& aUri,TUint32& aAppUid ) |
|
361 { |
|
362 CLOG( ( EClient, 0, _L( "-> RCookieManager::StoreCookie" ) ) ); |
|
363 StoreCookieAtClientSide(&aCookie,aUri.UriDes(),aAppUid); |
|
364 TInt err; |
|
365 |
|
366 TInt cookieSize = aCookie.Size( EFalse ); |
|
367 HBufC8* buf = HBufC8::New( cookieSize ); |
|
368 if ( buf ) |
|
369 { |
|
370 CLOG( ( EClient, 0, |
|
371 _L( "RCookieManager::StoreCookie, cookie size:%d" ), |
|
372 cookieSize ) ); |
|
373 |
|
374 TPtr8 bufDes( buf->Des() ); |
|
375 err = iCookiePacker.CliPackCookie( bufDes, aCookie ); |
|
376 |
|
377 if ( !err ) |
|
378 { |
|
379 //Appuid value only takes 8 chars |
|
380 HBufC* appbuf = HBufC::New(8); |
|
381 TPtr ptr(appbuf->Des()); |
|
382 ptr.AppendNum(aAppUid,EHex); |
|
383 err = DoStoreCookie( *buf, aUri.UriDes(),ptr ); |
|
384 delete appbuf; |
|
385 } |
|
386 |
|
387 delete buf; |
|
388 } |
|
389 else |
|
390 { |
|
391 err = KErrNoMemory; |
|
392 } |
|
393 |
|
394 CLOG( ( EClient, 0, |
|
395 _L( "<- RCookieManager::StoreCookie errcode%d" ), err ) ); |
|
396 |
|
397 return err; |
|
398 } |
|
399 |
|
400 // --------------------------------------------------------- |
|
401 // RCookieManager::GetCookiesL Newly Added |
|
402 // --------------------------------------------------------- |
|
403 // |
|
404 EXPORT_C void RCookieManager::GetCookiesL( const TDesC8& aUri, |
|
405 RPointerArray<CCookie>& aCookies, |
|
406 TBool& aCookie2Reqd,TUint32& aAppUid ) |
|
407 { |
|
408 CLOG( ( EClient, 0, _L( "-> RCookieManager::GetCookiesL" ) ) ); |
|
409 TBool cookiefound(EFalse); |
|
410 CCookieClientDataArray* cookieclientdataarray = CCookieClientDataArray::GetInstance(); |
|
411 if(cookieclientdataarray) |
|
412 { |
|
413 TInt clientarraycount = cookieclientdataarray->Count(); |
|
414 if (clientarraycount == 0) |
|
415 { |
|
416 TUint32 groupid = RProcess().SecureId().iId; |
|
417 TBool cookieSharableFlag(EFalse); |
|
418 TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag); |
|
419 CCookieClientData* cookieclientdata = CCookieClientData::NewL(groupid, aAppUid, cookieSharableFlag,ETrue); |
|
420 cookieclientdata->SetInitFlag(ETrue); |
|
421 cookieclientdataarray->AddClientGroupDataL(cookieclientdata); |
|
422 } |
|
423 else |
|
424 { |
|
425 |
|
426 CLOG( ( EClient, 0, _L( "-> RCookieManager::GetClientSideCookies:" ) ) ); |
|
427 //Gets the Cookie objects for aUri in case it is present |
|
428 //TInt clerr = cookieclientdata->GetClientSideCookies(aUri,aCookies,cookiefound); |
|
429 TInt clerr = GetClientSideCookies(aUri,aCookies,cookiefound,aAppUid); |
|
430 CLOG( ( EClient, 0, _L( "RCookieManager::GetClientSideCookies:cookiefound = %d" ), cookiefound ) ); |
|
431 |
|
432 } |
|
433 } |
|
434 if(!cookiefound) |
|
435 { |
|
436 aCookie2Reqd = EFalse; |
|
437 //Appuid value only takes 8 chars |
|
438 HBufC* appuidbuf = HBufC::NewL(8); |
|
439 TPtr ptr(appuidbuf->Des()); |
|
440 ptr.AppendNum(aAppUid,EHex); |
|
441 TInt size = 0; |
|
442 TPckg<TInt> pkgSize( size ); |
|
443 User::LeaveIfError( DoGetCookieSize( aUri, pkgSize, ptr ) ); |
|
444 delete appuidbuf; |
|
445 if ( size ) |
|
446 { |
|
447 HBufC8* buf = HBufC8::NewLC( size ); |
|
448 |
|
449 TPtr8 des( buf->Des() ); |
|
450 User::LeaveIfError( DoGetCookies( des ) ); |
|
451 |
|
452 // it seems this is the only place where we cannot avoid leaving |
|
453 // ==> we allocate memory for cookies when we fill up the cookie array. |
|
454 iCookiePacker.UnpackCookiesFromBufferL( *buf, aCookies ); |
|
455 |
|
456 TInt count = aCookies.Count(); |
|
457 for(TInt j=0; j<count; j++) |
|
458 { |
|
459 CLOG( ( EClient, 0, _L( "-> RCookieManager::StoreClientSideCookies: aUri=%S" ), &aUri ) ); |
|
460 //cookieclientdata->StoreCookieAtClientSide( aCookies[j],aUri ); |
|
461 StoreCookieAtClientSide( aCookies[j],aUri,aAppUid ); |
|
462 } |
|
463 TInt i = 0; |
|
464 TBool anyCookie2( EFalse ); |
|
465 TBool anyUnknownVersion( EFalse ); |
|
466 for ( ; i < count; i++ ) |
|
467 { |
|
468 if ( aCookies[i]->FromCookie2() ) |
|
469 { |
|
470 anyCookie2 = ETrue; |
|
471 anyUnknownVersion |= aCookies[i]->IsUnknownVersion(); |
|
472 } |
|
473 } |
|
474 |
|
475 // if there were no new-style cookies or a new version info is detected |
|
476 // then we have to send an extra cookie header indicating that we're |
|
477 // able to process new-style cookies |
|
478 if ( !anyCookie2 || anyUnknownVersion ) |
|
479 { |
|
480 aCookie2Reqd = ETrue; |
|
481 } |
|
482 |
|
483 CleanupStack::PopAndDestroy(); // buf |
|
484 } |
|
485 } |
|
486 CLOG( ( EClient, 0, _L( "<- RCookieManager::GetCookiesL" ) ) ); |
|
487 } |
|
488 |
|
489 // --------------------------------------------------------- |
|
490 // RCookieManager::Close for Widget related destruction during |
|
491 //uninstallation process of a widget |
|
492 // --------------------------------------------------------- |
|
493 // |
|
494 EXPORT_C TInt RCookieManager::ClearAllAppUidCookies(const TUint32& aAppUid) |
|
495 { |
|
496 CLOG(( EClient, 0, _L("-> RCookieManager::ClearCookies") )); |
|
497 //Client side cookie deletion specific to a appuid |
|
498 CCookieClientDataArray::GetInstance()->DestroyClientData(aAppUid); |
|
499 //Server side Cookie deletion specific to a appuid |
|
500 //Appuid value only takes 8 chars |
|
501 HBufC* buf = HBufC::NewLC(8); |
|
502 TPtr ptr(buf->Des()); |
|
503 ptr.AppendNum(aAppUid,EHex); |
|
504 TInt error = SendReceive(EClearAppUidCookies,TIpcArgs(ptr.Length(),&ptr)); |
|
505 CleanupStack::PopAndDestroy(); |
|
506 return error; |
|
507 } |
|
508 |
|
509 // --------------------------------------------------------- |
|
510 // RCookieManager::StoreCookieAtClientSide |
|
511 // --------------------------------------------------------- |
|
512 // |
|
513 void RCookieManager::StoreCookieAtClientSide( const CCookie* aCookie, const TDesC8& aUri,TUint32 aWidgetUid ) |
|
514 { |
|
515 CLOG( ( EClient, 0, _L( "-> RCookieManager::StoreCookieAtClientSide" ) ) ); |
|
516 TUint32 groupid = RProcess().SecureId().iId; |
|
517 CCookieClientDataArray* cookieclientdataarray = CCookieClientDataArray::GetInstance(); |
|
518 TInt count = cookieclientdataarray->Count(); |
|
519 TInt itemIndex =0; |
|
520 for(TInt i=0; i<count; i++) |
|
521 { |
|
522 if (cookieclientdataarray->At(i)->GetGroupId() == groupid |
|
523 && cookieclientdataarray->At(i)->GetCookieSharableFlag()) |
|
524 { |
|
525 itemIndex = i; |
|
526 break; |
|
527 } |
|
528 else if(cookieclientdataarray->At(i)->GetGroupId() == groupid |
|
529 && !(cookieclientdataarray->At(i)->GetCookieSharableFlag()) |
|
530 && cookieclientdataarray->At(i)->GetWidgetUid() == aWidgetUid) |
|
531 { |
|
532 itemIndex = i; |
|
533 break; |
|
534 } |
|
535 } |
|
536 CCookieClientData* cookieclientdata = cookieclientdataarray->At(itemIndex); |
|
537 cookieclientdata->StoreCookieAtClientSideL(aCookie,aUri); |
|
538 CLOG( ( EClient, 0, _L( "<- RCookieManager::StoreCookieAtClientSide" ) ) ); |
|
539 } |
|
540 |
|
541 // --------------------------------------------------------- |
|
542 // RCookieManager::GetClientSideCookies |
|
543 // --------------------------------------------------------- |
|
544 // |
|
545 TInt RCookieManager::GetClientSideCookies( const TDesC8& aRequestUri,RPointerArray<CCookie>& aCookies |
|
546 ,TBool& aCookieFound, TUint32 aWidgetUid ) |
|
547 { |
|
548 CLOG( ( EClient, 0, _L( "-> RCookieManager::GetClientSideCookies" ) ) ); |
|
549 TUint32 groupid = RProcess().SecureId().iId; |
|
550 //TInt itemIndex =0; |
|
551 CCookieClientData* cookieclientdata = NULL; |
|
552 CCookieClientDataArray* cookieclientdataarray = CCookieClientDataArray::GetInstance(); |
|
553 TInt count = cookieclientdataarray->Count(); |
|
554 if (count == 0) |
|
555 { |
|
556 TBool cookieSharableFlag(EFalse); |
|
557 TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag); |
|
558 cookieclientdata = CCookieClientData::NewL(groupid, aWidgetUid, cookieSharableFlag,ETrue); |
|
559 cookieclientdata->SetInitFlag(ETrue); |
|
560 cookieclientdataarray->AddClientGroupDataL(cookieclientdata); |
|
561 } else |
|
562 { |
|
563 //harendra: move this for loop in CCookieClientDataArray::Find(), it should index or object |
|
564 cookieclientdata = cookieclientdataarray->Find(groupid, aWidgetUid); |
|
565 } |
|
566 if(cookieclientdata) |
|
567 { |
|
568 if(!cookieclientdata->GetInitFlag()) |
|
569 { |
|
570 TBool cookieSharableFlag(EFalse); |
|
571 TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag); |
|
572 cookieclientdata->SetCookieCookieSharableFlag(cookieSharableFlag); |
|
573 } |
|
574 //cookieclientdata->SetInitFlag(ETrue); |
|
575 return cookieclientdata->GetClientSideCookies( aRequestUri,aCookies, aCookieFound ); |
|
576 } else |
|
577 { |
|
578 TBool cookieSharableFlag(EFalse); |
|
579 TInt err = GetCookieSharableFlagFromServer(cookieSharableFlag); |
|
580 if(err == KErrNone) |
|
581 { |
|
582 CCookieClientData* cookieclientdata |
|
583 = CCookieClientData::NewL(groupid, aWidgetUid, cookieSharableFlag,ETrue); |
|
584 cookieclientdataarray->AddClientGroupDataL(cookieclientdata); |
|
585 } |
|
586 } |
|
587 CLOG( ( EClient, 0, _L( "<- RCookieManager::GetClientSideCookies" ) ) ); |
|
588 return KErrNone; |
|
589 } |
|
590 |
270 // End of file |
591 // End of file |