emailservices/emailstore/message_store/server/src/ContainerStoreContainersTable.cpp
branchRCL_3
changeset 52 efd4f1afd43e
parent 29 6b8f3b30d0ec
equal deleted inserted replaced
29:6b8f3b30d0ec 52:efd4f1afd43e
   295 	iQuickPropertiesColNum = colSet->ColNo( KContainersTableQuickPropertiesCol );
   295 	iQuickPropertiesColNum = colSet->ColNo( KContainersTableQuickPropertiesCol );
   296 	iCountsColNum          = colSet->ColNo( KContainersTableCountsCol );
   296 	iCountsColNum          = colSet->ColNo( KContainersTableCountsCol );
   297     iIsRowEncryptedColNum  = colSet->ColNo( KContainersTableIsRowEncryptedCol );
   297     iIsRowEncryptedColNum  = colSet->ColNo( KContainersTableIsRowEncryptedCol );
   298 
   298 
   299 	CleanupStack::PopAndDestroy( colSet );
   299 	CleanupStack::PopAndDestroy( colSet );
   300 	
   300 
   301 	// Set the table's index to the ID index.
   301     // make sure KContainersTableParentIdIndex exists
   302 	User::LeaveIfError( iTable.SetIndex( KContainersTableIdIndex ) );
   302     TInt err = iTable.SetIndex( KContainersTableParentIdIndex );
       
   303     if ( err == KErrNotFound )
       
   304         {
       
   305         iUtils.CloseTable( iTable );
       
   306         CreateIndexL( KContainersTableName, KContainersTableParentIdIndex, KContainersTableParentIdCol );
       
   307         iUtils.OpenTableL( iTable, KContainersTableName );
       
   308         }
       
   309     else
       
   310         {
       
   311         User::LeaveIfError( err );
       
   312         }
       
   313 
       
   314     // Set the table's index to the ID index.
       
   315     User::LeaveIfError( iTable.SetIndex( KContainersTableIdIndex ) );
   303 	
   316 	
   304 	__LOG_EXIT
   317 	__LOG_EXIT
   305 	} // end OpenTableL
   318 	} // end OpenTableL
   306 
   319 
   307 // ==========================================================================
   320 // ==========================================================================
   346 	CleanupStack::PopAndDestroy( colSet );
   359 	CleanupStack::PopAndDestroy( colSet );
   347 	
   360 	
   348 	// Create table index.
   361 	// Create table index.
   349     CreateIndexL( KContainersTableName, KContainersTableIdIndex, KContainersTableIdCol );
   362     CreateIndexL( KContainersTableName, KContainersTableIdIndex, KContainersTableIdCol );
   350     CreateIndexL( KContainersTableName, KContainersTableParentIdIndex, KContainersTableParentIdCol );
   363     CreateIndexL( KContainersTableName, KContainersTableParentIdIndex, KContainersTableParentIdCol );
   351 	OpenTableL();
   364 
       
   365     OpenTableL();
   352 	
   366 	
   353 	__LOG_EXIT	
   367 	__LOG_EXIT	
   354 	} // end CreateTableL
   368 	} // end CreateTableL
   355 	
   369 	
   356 // ==========================================================================
   370 // ==========================================================================
   930         // Update the query to query the next ID to be searched.
   944         // Update the query to query the next ID to be searched.
   931         queryString.SetLength( queryLengthWithoutId );
   945         queryString.SetLength( queryLengthWithoutId );
   932 	    queryString.AppendNum( toBeSearched[0] );    	    
   946 	    queryString.AppendNum( toBeSearched[0] );    	    
   933         toBeSearched.Remove( 0 );
   947         toBeSearched.Remove( 0 );
   934         
   948         
   935         if ( aType == EMsgStorePartBits )
   949         if ( aType == EMsgStorePartBits || 
       
   950            ( ( aId & KContainerTypeMask ) == EMsgStoreMessageBits ) ||
       
   951            ( ( aId & KContainerTypeMask ) == EMsgStorePartBits ) )
   936         	{
   952         	{
   937         	//must sort the message parts by containerId in ascending order
   953         	//must sort the message parts by containerId in ascending order
   938         	// to preserve the same order as they are created
   954         	// to preserve the same order as they are created
   939     	    queryString.Append( KOrderBy );    	    
   955     	    queryString.Append( KOrderBy );    	    
   940     		queryString.Append( KContainersTableIdCol );
   956     		queryString.Append( KContainersTableIdCol );
  1214  */
  1230  */
  1215 TContainerId CContainerStoreContainersTable::FirstChildForDeleteL( TContainerId aId, TDbBookmark& aBookmark )
  1231 TContainerId CContainerStoreContainersTable::FirstChildForDeleteL( TContainerId aId, TDbBookmark& aBookmark )
  1216     {
  1232     {
  1217     __LOG_ENTER( "FirstChildForDeleteL" )
  1233     __LOG_ENTER( "FirstChildForDeleteL" )
  1218     __LOG_WRITE8_FORMAT1_INFO( "id=%x", aId )
  1234     __LOG_WRITE8_FORMAT1_INFO( "id=%x", aId )
  1219     
  1235 
  1220     TContainerId returnValue = KContainerInvalidId;
  1236     TContainerId returnValue = KContainerInvalidId;
  1221     
  1237     User::LeaveIfError( iTable.SetIndex( KContainersTableParentIdIndex ) );
  1222     TInt rc = iTable.SetIndex( KContainersTableParentIdIndex );
  1238     TRAP_IGNORE( returnValue = GetFirstChildForDeleteL( aId, aBookmark ) );
  1223     if ( rc == KErrNone )
  1239     //remember to set the index back
  1224         {
  1240     iTable.SetIndex( KContainersTableIdIndex );
  1225         TRAP_IGNORE(returnValue = GetFirstChildForDeleteL(aId, aBookmark));       
  1241 
  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
  1242     __LOG_EXIT
  1249     return returnValue;   
  1243     return returnValue;   
  1250     }
  1244     }
  1251 
  1245 
  1252 /*
  1246 /*
  1268         {
  1262         {
  1269         iTable.GetL();
  1263         iTable.GetL();
  1270         returnValue = iTable.ColUint32( iIdColNum );
  1264         returnValue = iTable.ColUint32( iIdColNum );
  1271         aBookmark = Bookmark();
  1265         aBookmark = Bookmark();
  1272         __LOG_WRITE8_FORMAT1_INFO( "found id=%x", returnValue )
  1266         __LOG_WRITE8_FORMAT1_INFO( "found id=%x", returnValue )
  1273         }        
  1267         }
  1274     __LOG_EXIT
  1268     __LOG_EXIT
  1275     return returnValue;   
  1269     return returnValue;   
  1276     }
  1270     }