emailservices/emailstore/message_store/server/src/ContainerStoreContainersTable.cpp
branchRCL_3
changeset 18 6b8f3b30d0ec
parent 0 8466d47a6819
child 20 efd4f1afd43e
equal deleted inserted replaced
17:67369d1b217f 18:6b8f3b30d0ec
   345 
   345 
   346 	CleanupStack::PopAndDestroy( colSet );
   346 	CleanupStack::PopAndDestroy( colSet );
   347 	
   347 	
   348 	// Create table index.
   348 	// Create table index.
   349     CreateIndexL( KContainersTableName, KContainersTableIdIndex, KContainersTableIdCol );
   349     CreateIndexL( KContainersTableName, KContainersTableIdIndex, KContainersTableIdCol );
   350 	
   350     CreateIndexL( KContainersTableName, KContainersTableParentIdIndex, KContainersTableParentIdCol );
   351 	OpenTableL();
   351 	OpenTableL();
   352 	
   352 	
   353 	__LOG_EXIT	
   353 	__LOG_EXIT	
   354 	} // end CreateTableL
   354 	} // end CreateTableL
   355 	
   355 	
  1206 void CContainerStoreContainersTable::SetEncryptedL( TBool aIsEncrypted )
  1206 void CContainerStoreContainersTable::SetEncryptedL( TBool aIsEncrypted )
  1207     {
  1207     {
  1208     iTable.SetColL( iIsRowEncryptedColNum, static_cast<TUint8>(aIsEncrypted) );
  1208     iTable.SetColL( iIsRowEncryptedColNum, static_cast<TUint8>(aIsEncrypted) );
  1209     }
  1209     }
  1210 
  1210 
  1211 
  1211 /*
       
  1212  * Search based on the parent ID. This will set the index if one exists and use the find if the index does not
       
  1213  * exists which could happen for a existing DB(IAD case)
       
  1214  */
       
  1215 TContainerId CContainerStoreContainersTable::FirstChildForDeleteL( TContainerId aId, TDbBookmark& aBookmark )
       
  1216     {
       
  1217     __LOG_ENTER( "FirstChildForDeleteL" )
       
  1218     __LOG_WRITE8_FORMAT1_INFO( "id=%x", aId )
       
  1219     
       
  1220     TContainerId returnValue = KContainerInvalidId;
       
  1221     
       
  1222     TInt rc = iTable.SetIndex( KContainersTableParentIdIndex );
       
  1223     if ( rc == KErrNone )
       
  1224         {
       
  1225         TRAP_IGNORE(returnValue = GetFirstChildForDeleteL(aId, aBookmark));       
       
  1226         //remember to set the index back
       
  1227         iTable.SetIndex( KContainersTableIdIndex );
       
  1228         }
       
  1229     else
       
  1230         {
       
  1231         //older version of the db does not have the index on parent id, so do the slow Find instead
       
  1232         const TUint bufSize = 60;
       
  1233         TBuf<bufSize> queryString;
       
  1234         
       
  1235         _LIT( KEquals, "=" );
       
  1236         
       
  1237         queryString.Copy( KContainersTableParentIdCol );
       
  1238         queryString.Append( KEquals );
       
  1239         queryString.AppendNum( aId );
       
  1240     
       
  1241         returnValue = FindL( queryString );
       
  1242         if ( returnValue != KContainerInvalidId )
       
  1243             {
       
  1244             aBookmark = Bookmark();
       
  1245             }
       
  1246         }
       
  1247     
       
  1248     __LOG_EXIT
       
  1249     return returnValue;   
       
  1250     }
       
  1251 
       
  1252 /*
       
  1253  * Search based on the parent ID. 
       
  1254  */
       
  1255 TContainerId CContainerStoreContainersTable::GetFirstChildForDeleteL( TContainerId aId, TDbBookmark& aBookmark )
       
  1256     {
       
  1257     __LOG_ENTER( "FirstChildForDeleteL" )
       
  1258     __LOG_WRITE8_FORMAT1_INFO( "id=%x", aId )
       
  1259     
       
  1260     TContainerId returnValue = KContainerInvalidId;
       
  1261     //Index on parent id, so we can Seek, faster than Find
       
  1262     if ( !iTable.SeekL( aId ) )
       
  1263         {
       
  1264         __LOG_WRITE_INFO( "No match found" )
       
  1265         returnValue = KContainerInvalidId;
       
  1266         }
       
  1267     else
       
  1268         {
       
  1269         iTable.GetL();
       
  1270         returnValue = iTable.ColUint32( iIdColNum );
       
  1271         aBookmark = Bookmark();
       
  1272         __LOG_WRITE8_FORMAT1_INFO( "found id=%x", returnValue )
       
  1273         }        
       
  1274     __LOG_EXIT
       
  1275     return returnValue;   
       
  1276     }