imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp
changeset 30 b67379558a75
parent 29 4bdfb6b5c9b4
child 31 d429f823a6b7
child 36 c5df59b4ae2d
equal deleted inserted replaced
29:4bdfb6b5c9b4 30:b67379558a75
    45 
    45 
    46 // Database path without drive letter
    46 // Database path without drive letter
    47 //Symbian^4 v5
    47 //Symbian^4 v5
    48 _LIT( KThumbnailDatabaseName, ":[102830AB]thumbnail_v5.db" );
    48 _LIT( KThumbnailDatabaseName, ":[102830AB]thumbnail_v5.db" );
    49 
    49 
    50 _LIT( KDrv, ":");
       
    51 
    50 
    52 // Allow access to database only for the server process
    51 // Allow access to database only for the server process
    53 const TSecurityPolicy KThumbnailDatabaseSecurityPolicy( TSecureId(
    52 const TSecurityPolicy KThumbnailDatabaseSecurityPolicy( TSecureId(
    54     THUMBNAIL_MANAGER_SERVER_UID ));
    53     THUMBNAIL_MANAGER_SERVER_UID ));
    55 
    54 
   546     
   545     
   547     RSqlStatement stmt;
   546     RSqlStatement stmt;
   548     TInt column = 0;   
   547     TInt column = 0;   
   549     TInt rowStatus = 0;
   548     TInt rowStatus = 0;
   550     TInt64 inforows = -1;
   549     TInt64 inforows = -1;
       
   550     TInt64 infocount = -1;
   551     TInt64 datarows = -1;
   551     TInt64 datarows = -1;
       
   552     TInt64 datacount = -1;
   552     
   553     
   553     TInt ret = stmt.Prepare( iDatabase, KGetInfoRowID );
   554     TInt ret = stmt.Prepare( iDatabase, KGetInfoRowID );
   554     if(ret < 0)
   555     if(ret < 0)
   555         {
   556         {
   556         stmt.Close();
   557         stmt.Close();
   557         TN_DEBUG1( "CThumbnailStore::CheckRowIDs() failed 1 %d");
   558         TN_DEBUG1( "CThumbnailStore::CheckRowIDs() KGetInfoRowID failed %d");
   558         return KErrNotSupported;
   559         return KErrNotSupported;
   559         }
   560         }
   560     rowStatus = stmt.Next();
   561     rowStatus = stmt.Next();
   561                 
   562                 
   562     if ( rowStatus == KSqlAtRow)    
   563     if ( rowStatus == KSqlAtRow)    
   570         {
   571         {
   571 #ifdef _DEBUG
   572 #ifdef _DEBUG
   572         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
   573         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
   573         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
   574         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
   574 #endif
   575 #endif
   575         return ret;
   576         return KErrNotSupported;
       
   577         }
       
   578     
       
   579     ret = stmt.Prepare( iDatabase, KGetInfoCount );
       
   580     if(ret < 0)
       
   581         {
       
   582         stmt.Close();
       
   583         TN_DEBUG1( "CThumbnailStore::CheckRowIDs() KGetInfoCount failed %d");
       
   584         return KErrNotSupported;
       
   585         }
       
   586     rowStatus = stmt.Next();
       
   587                 
       
   588     if ( rowStatus == KSqlAtRow)    
       
   589         {        
       
   590         infocount = stmt.ColumnInt64( column );  
       
   591         }
       
   592                 
       
   593     stmt.Close();
       
   594     
       
   595     if(rowStatus < 0)
       
   596         {
       
   597 #ifdef _DEBUG
       
   598         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
       
   599         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
       
   600 #endif
       
   601         return KErrNotSupported;
   576         }
   602         }
   577             
   603             
   578     ret = stmt.Prepare( iDatabase, KGetDataRowID );
   604     ret = stmt.Prepare( iDatabase, KGetDataRowID );
   579     if(ret < 0)
   605     if(ret < 0)
   580         {
   606         {
   581         stmt.Close();
   607         stmt.Close();
   582         TN_DEBUG1( "CThumbnailStore::CheckRowIDs() failed 2");
   608         TN_DEBUG1( "CThumbnailStore::CheckRowIDs() KGetDataRowID failed");
   583         return KErrNotSupported;
   609         return KErrNotSupported;
   584         }
   610         }
   585     rowStatus = stmt.Next();
   611     rowStatus = stmt.Next();
   586                        
   612                        
   587     if ( rowStatus == KSqlAtRow)    
   613     if ( rowStatus == KSqlAtRow)    
   595         {
   621         {
   596 #ifdef _DEBUG
   622 #ifdef _DEBUG
   597         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
   623         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
   598         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
   624         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
   599 #endif
   625 #endif
   600         return ret;
   626         return KErrNotSupported;
   601         }
   627         }
   602             
   628     
   603     if( inforows != datarows)
   629     ret = stmt.Prepare( iDatabase, KGetInfoDataCount );
       
   630     if(ret < 0)
       
   631         {
       
   632         stmt.Close();
       
   633         TN_DEBUG1( "CThumbnailStore::CheckRowIDs() KGetInfoDataCount failed %d");
       
   634         return KErrNotSupported;
       
   635         }
       
   636     rowStatus = stmt.Next();
       
   637                 
       
   638     if ( rowStatus == KSqlAtRow)    
       
   639         {        
       
   640         datacount = stmt.ColumnInt64( column );  
       
   641         }
       
   642                 
       
   643     stmt.Close();
       
   644     
       
   645     if(rowStatus < 0)
       
   646         {
       
   647 #ifdef _DEBUG
       
   648         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
       
   649         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
       
   650 #endif
       
   651         return KErrNotSupported;
       
   652         }
       
   653     
       
   654     TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - inforows %Ld", inforows );
       
   655     TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - infocount %Ld", infocount );
       
   656     TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - datarows %Ld", datarows );
       
   657     TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - datacount %Ld", datacount );
       
   658             
       
   659     if( inforows != datarows || datacount != infocount)
   604         {
   660         {
   605         TN_DEBUG1( "CThumbnailStore::CheckRowIDsL() - tables out of sync" );
   661         TN_DEBUG1( "CThumbnailStore::CheckRowIDsL() - tables out of sync" );
   606         return KErrNotSupported;
   662         return KErrNotSupported;
   607         }  
   663         }  
   608     else
   664     else
  1353                 stream.Open( *buf );
  1409                 stream.Open( *buf );
  1354                 aThumbnail->ExternalizeL( stream );
  1410                 aThumbnail->ExternalizeL( stream );
  1355             
  1411             
  1356                 StoreThumbnailL( *path, buf->Ptr( 0 ), aThumbnail->SizeInPixels(),
  1412                 StoreThumbnailL( *path, buf->Ptr( 0 ), aThumbnail->SizeInPixels(),
  1357                                  aOriginalSize, EThumbnailFormatFbsBitmap, flags, 
  1413                                  aOriginalSize, EThumbnailFormatFbsBitmap, flags, 
  1358                                  aThumbnailSize, aModified);
  1414                                  aThumbnailSize, aModified, aThumbFromPath);
  1359   
  1415   
  1360                 CleanupStack::PopAndDestroy( buf );
  1416                 CleanupStack::PopAndDestroy( buf );
  1361                 }
  1417                 }
  1362             
  1418             
  1363             break;
  1419             break;
  2611 // -----------------------------------------------------------------------------
  2667 // -----------------------------------------------------------------------------
  2612 //
  2668 //
  2613 void CThumbnailStore::StripDriveLetterL( TDes& aPath )
  2669 void CThumbnailStore::StripDriveLetterL( TDes& aPath )
  2614     {
  2670     {
  2615     TInt pos = aPath.Find(KDrv);
  2671     TInt pos = aPath.Find(KDrv);
       
  2672     TInt pos2 = aPath.Find(KBackSlash);
  2616     
  2673     
  2617     // if URI contains drive letter
  2674     // if URI contains drive letter
  2618     if ( pos == 1 )
  2675     if ( pos == 1 )
  2619         {
  2676         {
  2620         aPath.Delete(0,pos+1);
  2677         // normal URI
       
  2678         if ( pos2 == 2 )
       
  2679             {
       
  2680             aPath.Delete(0,pos+1);
       
  2681             }
       
  2682         // virtual URI
       
  2683         else
       
  2684             {
       
  2685             aPath.Replace(0,2,KBackSlash);
       
  2686             }
  2621         }
  2687         }
  2622     }
  2688     }
  2623 
  2689 
  2624 // -----------------------------------------------------------------------------
  2690 // -----------------------------------------------------------------------------
  2625 // CheckDbState
  2691 // CheckDbState