31 //column name for Uid's of plugins in blacklist database |
31 //column name for Uid's of plugins in blacklist database |
32 _LIT( Kuid , "uid" ); |
32 _LIT( Kuid , "uid" ); |
33 //column name for version numbers of plugins in blacklist database |
33 //column name for version numbers of plugins in blacklist database |
34 _LIT( Kversion , "version" ); |
34 _LIT( Kversion , "version" ); |
35 // The max length for creating sql query for KBlistSqlFormatSeek format |
35 // The max length for creating sql query for KBlistSqlFormatSeek format |
36 const TInt KBlistSqlStringMaxLength(40); |
36 const TInt KBlistSqlStringMaxLength(50); |
37 //SQL query to fetch the records with given uid |
37 //SQL query to fetch the records with given uid |
38 _LIT(KBlistSqlFormatSeek , "SELECT * FROM table WHERE uid=%d"); |
38 _LIT(KBlistSqlFormatSeek , "SELECT * FROM table WHERE uid=%d"); |
39 //SQL query to delete the records with given uid |
39 //SQL query to delete the records with given uid |
40 _LIT(KBlistSqlDelete, "DELETE FROM table WHERE uid=%d"); |
40 _LIT(KBlistSqlDelete, "DELETE FROM table WHERE uid=%d"); |
41 //SQL query to fetch all the records in database |
41 //SQL query to fetch all the records in database |
42 _LIT(KBlistSqlFormatAll , "SELECT * FROM table"); |
42 _LIT(KBlistSqlFormatAll , "SELECT * FROM table"); |
43 _LIT(KDriveC, "c:"); |
43 _LIT(KDriveC, "c:"); |
|
44 //Unload plugins Table name in blacklist database |
|
45 _LIT( KBLUnloadTableName , "unloadtable" ); |
|
46 //SQL query to fetch all the records in unload table |
|
47 _LIT(KUnloadlistSqlFormatAll , "SELECT * FROM unloadtable"); |
|
48 //SQL query to delete the records with given uid in unload table |
|
49 _LIT(KunloadlistSqlDelete, "DELETE FROM unloadtable WHERE uid=%d"); |
|
50 //SQL query to fetch the records with given uid from unload table |
|
51 _LIT(KUnloadlistSqlFormatSeek , "SELECT * FROM unloadtable WHERE uid=%d"); |
44 // ----------------------------------------------------------------------------- |
52 // ----------------------------------------------------------------------------- |
45 // CBlacklistDb::NewL() |
53 // CBlacklistDb::NewL() |
46 // ----------------------------------------------------------------------------- |
54 // ----------------------------------------------------------------------------- |
47 // |
55 // |
48 CBlacklistDb* CBlacklistDb::NewL() |
56 CBlacklistDb* CBlacklistDb::NewL() |
370 |
378 |
371 //create the database |
379 //create the database |
372 User::LeaveIfError( iDatabase.Create( iFs , datafile ) ); |
380 User::LeaveIfError( iDatabase.Create( iFs , datafile ) ); |
373 CDbColSet* columns = CreateColumnSetLC();//creates the columns and push to cleanupstack |
381 CDbColSet* columns = CreateColumnSetLC();//creates the columns and push to cleanupstack |
374 User::LeaveIfError( iDatabase.CreateTable( KBlacklistTableName , *columns ) ); |
382 User::LeaveIfError( iDatabase.CreateTable( KBlacklistTableName , *columns ) ); |
|
383 //Add table to store the unload plugins |
|
384 CDbColSet* unloadcolumns = CreateUnloadColumnSetLC(); //creates the columns and push to cleanupstack |
|
385 User::LeaveIfError( iDatabase.CreateTable( KBLUnloadTableName , *unloadcolumns ) ); |
375 //clean up of variables (columns and dataFile) |
386 //clean up of variables (columns and dataFile) |
376 CleanupStack::PopAndDestroy( columns ); |
387 CleanupStack::PopAndDestroy( 2 ); |
377 |
388 |
378 CPIXLOGSTRING("CBlacklistDb::CreateDBL(): Exit"); |
389 CPIXLOGSTRING("CBlacklistDb::CreateDBL(): Exit"); |
379 OstTraceFunctionExit0( CBLACKLISTDB_CREATEDBL_EXIT ); |
390 OstTraceFunctionExit0( CBLACKLISTDB_CREATEDBL_EXIT ); |
380 } |
391 } |
381 |
392 |
404 CPIXLOGSTRING("CBlacklistDb::CreateColumnSetLC(): Exit"); |
415 CPIXLOGSTRING("CBlacklistDb::CreateColumnSetLC(): Exit"); |
405 |
416 |
406 OstTraceFunctionExit0( CBLACKLISTDB_CREATECOLUMNSETLC_EXIT ); |
417 OstTraceFunctionExit0( CBLACKLISTDB_CREATECOLUMNSETLC_EXIT ); |
407 return columns; // columns stays on CleanupStack |
418 return columns; // columns stays on CleanupStack |
408 } |
419 } |
|
420 |
|
421 // ----------------------------------------------------------------------------- |
|
422 // CBlacklistDb::CreateUnloadColumnSetLC |
|
423 // ----------------------------------------------------------------------------- |
|
424 // |
|
425 CDbColSet* CBlacklistDb::CreateUnloadColumnSetLC() |
|
426 { |
|
427 OstTraceFunctionEntry0( CBLACKLISTDB_CREATEUNLOADCOLUMNSETLC_ENTRY ); |
|
428 CDbColSet* columns = CDbColSet::NewLC(); |
|
429 |
|
430 //Add uid column |
|
431 TDbCol col( Kuid , EDbColInt32 ); |
|
432 col.iAttributes = TDbCol::ENotNull ; |
|
433 columns->AddL( col ); |
|
434 |
|
435 OstTraceFunctionExit0( CBLACKLISTDB_CREATEUNLOADCOLUMNSETLC_EXIT ); |
|
436 return columns; // columns stays on CleanupStack |
|
437 } |
|
438 |
|
439 // ----------------------------------------------------------------------------- |
|
440 // CBlacklistDb::AddtoUnloadListL |
|
441 // ----------------------------------------------------------------------------- |
|
442 // |
|
443 TInt CBlacklistDb::AddtoUnloadListL( TInt32 aPluginUid ) |
|
444 { |
|
445 OstTraceFunctionEntry0( CBLACKLISTDB_ADDTOUNLOADLISTL_ENTRY ); |
|
446 if ( !iOpened ) |
|
447 return KErrNotReady; |
|
448 |
|
449 TInt err; |
|
450 //Prepare the view |
|
451 RDbView dbView; |
|
452 CleanupClosePushL( dbView ); |
|
453 |
|
454 err = dbView.Prepare( iDatabase , TDbQuery( KUnloadlistSqlFormatAll ) ) ; |
|
455 |
|
456 if ( err == KErrNone ) |
|
457 { |
|
458 TRAP( err , dbView.InsertL() ); |
|
459 CDbColSet* colSet = dbView.ColSetL(); |
|
460 TDbColNo uidcolno = colSet->ColNo( Kuid ); |
|
461 dbView.SetColL( uidcolno , aPluginUid ); |
|
462 dbView.PutL(); |
|
463 //If addition failed, rollback |
|
464 if(err != KErrNone) |
|
465 { |
|
466 iDatabase.Rollback(); |
|
467 } |
|
468 } |
|
469 CleanupStack::PopAndDestroy( &dbView ); // dbView/ |
|
470 User::LeaveIfError( iDatabase.Compact() ); |
|
471 |
|
472 OstTraceFunctionExit0( CBLACKLISTDB_ADDTOUNLOADLISTL_EXIT ); |
|
473 return err; |
|
474 } |
|
475 // ----------------------------------------------------------------------------- |
|
476 // CBlacklistDb::RemoveFromUnloadListL |
|
477 // ----------------------------------------------------------------------------- |
|
478 // |
|
479 void CBlacklistDb::RemoveFromUnloadListL( TInt32 aPluginUid ) |
|
480 { |
|
481 OstTraceFunctionEntry0( CBLACKLISTDB_REMOVEFROMUNLOADLISTL_ENTRY ); |
|
482 if ( !iOpened ) |
|
483 return ; |
|
484 |
|
485 //Remove the item record to database |
|
486 // Create the sql statement. KBlistSqlDelete |
|
487 TBuf<KBlistSqlStringMaxLength> sql; |
|
488 sql.Format( KunloadlistSqlDelete , aPluginUid ); |
|
489 |
|
490 //delete the row. |
|
491 TInt rowCount( iDatabase.Execute(sql) ); |
|
492 if(rowCount > 0) |
|
493 { |
|
494 OstTrace0( TRACE_NORMAL, CBLACKLISTDB_REMOVEFROMUNLOADLISTL, "CBlacklistDb::RemoveFromUnloadListL :: removed UID succesfully" ); |
|
495 CPIXLOGSTRING("CBlacklistDb::RemoveFromUnloadListL(): Removed UID succesfully"); |
|
496 } |
|
497 else |
|
498 { |
|
499 OstTrace0( TRACE_NORMAL, DUP1_CBLACKLISTDB_REMOVEFROMUNLOADLISTL, "CBlacklistDb::RemoveFromUnloadListL:: UID not found" ); |
|
500 CPIXLOGSTRING("CBlacklistDb::RemoveFromUnloadListL(): UID not found"); |
|
501 } |
|
502 CPIXLOGSTRING("CBlacklistDb::RemoveFromUnloadListL(): Exit"); |
|
503 |
|
504 OstTraceFunctionExit0( CBLACKLISTDB_REMOVEFROMUNLOADLISTL_EXIT ); |
|
505 return ; |
|
506 } |
|
507 |
|
508 // ----------------------------------------------------------------------------- |
|
509 // CBlacklistDb::FindFromUnloadListL |
|
510 // ----------------------------------------------------------------------------- |
|
511 // |
|
512 TBool CBlacklistDb::FindFromUnloadListL( TInt32 aPluginUid ) |
|
513 { |
|
514 OstTraceFunctionEntry0( CBLACKLISTDB_FINDFROMUNLOADLISTL_ENTRY ); |
|
515 CPIXLOGSTRING2("CBlacklistDb::FindFromUnloadListL(): Uid = %x " , aPluginUid ); |
|
516 |
|
517 if ( !iOpened ) |
|
518 return EFalse; |
|
519 |
|
520 //Check if the item is available in database |
|
521 //Prepare the sql |
|
522 TBuf<KBlistSqlStringMaxLength> sql; |
|
523 sql.Format( KUnloadlistSqlFormatSeek , aPluginUid ); |
|
524 TBool found = EFalse; |
|
525 //Prepare the view |
|
526 RDbView dbView; |
|
527 CleanupClosePushL( dbView ); |
|
528 |
|
529 User::LeaveIfError( dbView.Prepare( iDatabase , TDbQuery(sql) , RDbView::EReadOnly ) ); |
|
530 User::LeaveIfError( dbView.EvaluateAll() ); |
|
531 |
|
532 TInt isAtRow( dbView.FirstL() ); |
|
533 |
|
534 if ( isAtRow ) |
|
535 { |
|
536 OstTrace0( TRACE_NORMAL, CBLACKLISTDB_FINDFROMUNLOADLISTL, "CBlacklistDb::FindFromUnloadListL::UID found" ); |
|
537 CPIXLOGSTRING("CBlacklistDb::FindFromUnloadListL(): UID found"); |
|
538 found = ETrue; |
|
539 } |
|
540 CleanupStack::PopAndDestroy( &dbView ); // dbView/ |
|
541 OstTraceFunctionExit0( CBLACKLISTDB_FINDFROMUNLOADLISTL_EXIT ); |
|
542 return found; |
|
543 } |