emailservices/emailstore/message_store/server/src/ContainerStoreGeneralTable.cpp
changeset 76 38bf5461e270
parent 0 8466d47a6819
equal deleted inserted replaced
74:6c59112cfd31 76:38bf5461e270
   202 // ==========================================================================
   202 // ==========================================================================
   203 TContainerId CContainerStoreGeneralTable::AssignNextIdL()
   203 TContainerId CContainerStoreGeneralTable::AssignNextIdL()
   204 	{
   204 	{
   205 	// Read and increment the next folder ID from the general table.
   205 	// Read and increment the next folder ID from the general table.
   206 	
   206 	
   207   	iTable.FirstL();
   207   	TContainerId id=0;
   208 	PrepareRowForUpdateLC();
   208   	
   209 	
   209   	if(iTable.FirstL()){
   210 	TContainerId id = iTable.ColUint32( iNextIdColNum );
   210         PrepareRowForUpdateLC();
   211 
   211         
   212 	iTable.SetColL( iNextIdColNum, id+1 );
   212         id = iTable.ColUint32( iNextIdColNum );
   213 
   213     
   214 	PutRowUpdatesL();
   214         iTable.SetColL( iNextIdColNum, id+1 );
   215 	
   215     
   216 	//iTable.FirstL();
   216         PutRowUpdatesL();
       
   217         
       
   218         //iTable.FirstL();
       
   219   	}
   217 	
   220 	
   218 	return id;
   221 	return id;
   219 	} // end AssignNextIdL
   222 	} // end AssignNextIdL
   220 
   223 
   221 // ==========================================================================
   224 // ==========================================================================
   222 // FUNCTION: IsEncryptionOnL
   225 // FUNCTION: IsEncryptionOnL
   223 // ==========================================================================
   226 // ==========================================================================
   224 TBool CContainerStoreGeneralTable::IsEncryptionOnL()
   227 TBool CContainerStoreGeneralTable::IsEncryptionOnL()
   225 {
   228 {
   226 	iTable.FirstL();
   229     TBool ret = EFalse;
   227   	iTable.GetL();
   230     
   228 
   231 	if(iTable.FirstL()){
   229   	return iTable.ColUint8( iEncryptionFlagColNum );
   232 	    iTable.GetL();
       
   233 	    ret = iTable.ColUint8( iEncryptionFlagColNum );
       
   234 	}
       
   235   	return ret;
   230 }
   236 }
   231 
   237 
   232 // ==========================================================================
   238 // ==========================================================================
   233 // FUNCTION: SetEncryptionFlagL
   239 // FUNCTION: SetEncryptionFlagL
   234 // ==========================================================================
   240 // ==========================================================================
   235 void CContainerStoreGeneralTable::SetEncryptionFlagL( TBool aNewFlag )
   241 void CContainerStoreGeneralTable::SetEncryptionFlagL( TBool aNewFlag )
   236 {
   242 {
   237 	TBool curFlag = IsEncryptionOnL();
   243 	TBool curFlag = IsEncryptionOnL();
   238 	if ( curFlag != aNewFlag )
   244 	if ( curFlag != aNewFlag )
   239 	{
   245 	{
   240 		iTable.FirstL();
   246 		if(iTable.FirstL()){
   241 		PrepareRowForUpdateLC();
   247 		    PrepareRowForUpdateLC();
   242 	
   248 	
   243 		iTable.SetColL( iEncryptionFlagColNum, aNewFlag );
   249 		    iTable.SetColL( iEncryptionFlagColNum, aNewFlag );
   244 	
   250 	
   245 		PutRowUpdatesL();
   251 		    PutRowUpdatesL();
       
   252 		}
   246 		
   253 		
   247 		//iTable.FirstL();
   254 		//iTable.FirstL();
   248 	}
   255 	}
   249 }
   256 }
   250 
   257 
   251 // ==========================================================================
   258 // ==========================================================================
   252 // FUNCTION: AuthenticationDataPresentL
   259 // FUNCTION: AuthenticationDataPresentL
   253 // ==========================================================================
   260 // ==========================================================================
   254 TBool CContainerStoreGeneralTable::AuthenticationDataPresentL()
   261 TBool CContainerStoreGeneralTable::AuthenticationDataPresentL()
   255 {
   262 {
   256   	iTable.FirstL();
   263     TInt authenticationDataLength = 0;
   257   	iTable.GetL();
   264     
   258   	TInt authenticationDataLength = iTable.ColLength( iAuthenticationDataColNum );
   265   	if(iTable.FirstL()){
       
   266   	    iTable.GetL();
       
   267   	    authenticationDataLength = iTable.ColLength( iAuthenticationDataColNum );
       
   268   	}
   259 
   269 
   260     return ( authenticationDataLength > 0 );    
   270     return ( authenticationDataLength > 0 );    
   261 } // end AuthenticationDataPresentL
   271 } // end AuthenticationDataPresentL
   262     
   272     
   263 // ==========================================================================
   273 // ==========================================================================
   264 // FUNCTION: SetAuthenticationDataL
   274 // FUNCTION: SetAuthenticationDataL
   265 // ==========================================================================
   275 // ==========================================================================
   266 void CContainerStoreGeneralTable::SetAuthenticationDataL( const TDesC8& aBuffer )
   276 void CContainerStoreGeneralTable::SetAuthenticationDataL( const TDesC8& aBuffer )
   267 {
   277 {
   268   	iTable.FirstL();  	
   278   	if(iTable.FirstL()){  	
   269 	PrepareRowForUpdateLC();
   279   	    PrepareRowForUpdateLC();
   270     
   280     
   271 	iTable.SetColL( iAuthenticationDataColNum, aBuffer );
   281   	    iTable.SetColL( iAuthenticationDataColNum, aBuffer );
   272 
   282 
   273 	PutRowUpdatesL();
   283   	    PutRowUpdatesL();
       
   284   	}
   274 	
   285 	
   275 	//iTable.FirstL();
   286 	//iTable.FirstL();
   276 } // end SetAuthenticationDataL
   287 } // end SetAuthenticationDataL
   277 
   288 
   278 // ==========================================================================
   289 // ==========================================================================
   279 // FUNCTION: GetAuthenticationDataL
   290 // FUNCTION: GetAuthenticationDataL
   280 // ==========================================================================
   291 // ==========================================================================
   281 void CContainerStoreGeneralTable::GetAuthenticationDataL( RBuf8& aBuffer )
   292 void CContainerStoreGeneralTable::GetAuthenticationDataL( RBuf8& aBuffer )
   282 {
   293 {
   283   	iTable.FirstL();
   294   	if(iTable.FirstL()){
   284   	iTable.GetL();
   295         iTable.GetL();        
   285     
   296         aBuffer.CreateL( iTable.ColDes8( iAuthenticationDataColNum ) );
   286     aBuffer.CreateL( iTable.ColDes8( iAuthenticationDataColNum ) );
   297   	}
   287 } // end GetAuthenticationDataL
   298 } // end GetAuthenticationDataL
   288 		
   299 		
   289 // ==========================================================================
   300 // ==========================================================================
   290 // FUNCTION: EncryptionStateL
   301 // FUNCTION: EncryptionStateL
   291 // ==========================================================================
   302 // ==========================================================================
   292 TEncryptionState CContainerStoreGeneralTable::EncryptionStateL()
   303 TEncryptionState CContainerStoreGeneralTable::EncryptionStateL()
   293 {
   304 {
   294 	iTable.FirstL();
   305     TEncryptionState encryptionState = EMsgStoreESIdle;
   295 	iTable.GetL();
   306 
   296 
   307 	if(iTable.FirstL()){
   297     TEncryptionState encryptionState = static_cast<TEncryptionState>(iTable.ColUint8( iEncryptionStateColNum ));
   308 	    iTable.GetL();
       
   309 	    encryptionState = static_cast<TEncryptionState>(iTable.ColUint8( iEncryptionStateColNum ));
       
   310 	}
   298     return encryptionState;
   311     return encryptionState;
   299     
   312     
   300 } // end EncryptionStateL
   313 } // end EncryptionStateL
   301 
   314 
   302 // ==========================================================================
   315 // ==========================================================================
   303 // FUNCTION: SetEncryptionStateL
   316 // FUNCTION: SetEncryptionStateL
   304 // ==========================================================================
   317 // ==========================================================================
   305 void CContainerStoreGeneralTable::SetEncryptionStateL( TEncryptionState aEncryptionState )
   318 void CContainerStoreGeneralTable::SetEncryptionStateL( TEncryptionState aEncryptionState )
   306 {
   319 {
   307 	iTable.FirstL();  	
   320 	if(iTable.FirstL()){
   308 	PrepareRowForUpdateLC();
   321 	    PrepareRowForUpdateLC();
   309     
   322     
   310 	iTable.SetColL( iEncryptionStateColNum, static_cast<TUint8>(aEncryptionState) );
   323 	    iTable.SetColL( iEncryptionStateColNum, static_cast<TUint8>(aEncryptionState) );
   311 
   324 
   312 	PutRowUpdatesL();
   325 	    PutRowUpdatesL();
       
   326 	}
   313 	
   327 	
   314 	//iTable.FirstL();
   328 	//iTable.FirstL();
   315 } // end SetEncryptionStateL
   329 } // end SetEncryptionStateL
   316 
   330 
   317 // ==========================================================================
   331 // ==========================================================================
   318 // FUNCTION: IsAuthenticateRequiredL
   332 // FUNCTION: IsAuthenticateRequiredL
   319 // ==========================================================================
   333 // ==========================================================================
   320 TBool CContainerStoreGeneralTable::IsAuthenticateRequiredL()
   334 TBool CContainerStoreGeneralTable::IsAuthenticateRequiredL()
   321 {
   335 {
   322     iTable.FirstL();
   336     TBool ret = EFalse;
   323     iTable.GetL();
   337     if(iTable.FirstL()){
   324 
   338         iTable.GetL();
   325     return iTable.ColUint8( iAuthenticationRequiredColNum );
   339         ret = iTable.ColUint8( iAuthenticationRequiredColNum );
       
   340     }
       
   341     return ret;
   326 }
   342 }
   327 
   343 
   328 // ==========================================================================
   344 // ==========================================================================
   329 // FUNCTION: SetAuthenticationRequiredL
   345 // FUNCTION: SetAuthenticationRequiredL
   330 // ==========================================================================
   346 // ==========================================================================
   331 void CContainerStoreGeneralTable::SetAuthenticationRequiredL( TBool aFlag )
   347 void CContainerStoreGeneralTable::SetAuthenticationRequiredL( TBool aFlag )
   332     {
   348     {
   333     iTable.FirstL();    
   349     if(iTable.FirstL()){
   334     PrepareRowForUpdateLC();
   350         PrepareRowForUpdateLC();
   335     
   351     
   336     iTable.SetColL( iAuthenticationRequiredColNum, static_cast<TUint8>(aFlag) );
   352         iTable.SetColL( iAuthenticationRequiredColNum, static_cast<TUint8>(aFlag) );
   337 
   353 
   338     PutRowUpdatesL();
   354         PutRowUpdatesL();
       
   355     }
   339     
   356     
   340     //iTable.FirstL();
   357     //iTable.FirstL();
   341     }
   358     }
   342 
   359 
   343 // ==========================================================================
   360 // ==========================================================================
   344 // FUNCTION: MaxMruCountL
   361 // FUNCTION: MaxMruCountL
   345 // ==========================================================================
   362 // ==========================================================================
   346 TUint CContainerStoreGeneralTable::MaxMruCountL()
   363 TUint CContainerStoreGeneralTable::MaxMruCountL()
   347     {
   364     {
   348     iTable.FirstL();
   365     TUint ret = 0;
   349     iTable.GetL();
   366     
   350 
   367     if(iTable.FirstL()){
   351     return iTable.ColUint( iMaxMruCountColNum );
   368         iTable.GetL();
       
   369         ret = iTable.ColUint( iMaxMruCountColNum );
       
   370     }
       
   371     
       
   372     return ret; 
   352     }
   373     }
   353 
   374 
   354 // ==========================================================================
   375 // ==========================================================================
   355 // FUNCTION: SetMaxMruCountL
   376 // FUNCTION: SetMaxMruCountL
   356 // ==========================================================================
   377 // ==========================================================================
   357 void CContainerStoreGeneralTable::SetMaxMruCountL( TUint aCount )
   378 void CContainerStoreGeneralTable::SetMaxMruCountL( TUint aCount )
   358     {
   379     {
   359     iTable.FirstL();    
   380     if(iTable.FirstL()){    
   360     PrepareRowForUpdateLC();
   381         PrepareRowForUpdateLC();
   361     
   382     
   362     iTable.SetColL( iMaxMruCountColNum, aCount );
   383         iTable.SetColL( iMaxMruCountColNum, aCount );
   363 
   384 
   364     PutRowUpdatesL();
   385         PutRowUpdatesL();
   365     
   386     
   366     //iTable.FirstL();
   387         //iTable.FirstL();
       
   388         }
   367     }
   389     }
   368 
   390 
   369 TUint CContainerStoreGeneralTable::CurMruNumberL()
   391 TUint CContainerStoreGeneralTable::CurMruNumberL()
   370     {
   392     {
   371     iTable.FirstL();
   393     int ret = 0;
   372     iTable.GetL();
   394     if(iTable.FirstL()){
   373 
   395         iTable.GetL();
   374     return iTable.ColUint( iCurMruNumberColNum );
   396         ret = iTable.ColUint( iCurMruNumberColNum );
       
   397     }
       
   398 
       
   399     return ret;
   375     }
   400     }
   376 
   401 
   377 void CContainerStoreGeneralTable::SetCurMruNumberL( TUint aNum )
   402 void CContainerStoreGeneralTable::SetCurMruNumberL( TUint aNum )
   378     {
   403     {
   379     iTable.FirstL();    
   404     if(iTable.FirstL()){
   380     PrepareRowForUpdateLC();
   405         PrepareRowForUpdateLC();
   381     
   406     
   382     iTable.SetColL( iCurMruNumberColNum, aNum );
   407         iTable.SetColL( iCurMruNumberColNum, aNum );
   383 
   408 
   384     PutRowUpdatesL();
   409         PutRowUpdatesL();
       
   410     }
   385     
   411     
   386     //iTable.FirstL();
   412     //iTable.FirstL();
   387     }
   413     }
   388 
   414 
   389 
   415