messagingfw/msgsrvnstore/server/src/msvdbadapter.cpp
changeset 15 ff168ad79dda
parent 0 8e480a14352b
child 35 f8ad95794a08
child 36 e7635922c074
equal deleted inserted replaced
3:28ae839b4c09 15:ff168ad79dda
    46 	//Main (dummy) DB name.
    46 	//Main (dummy) DB name.
    47 	#if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)
    47 	#if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)
    48 		_LIT(KMainDummyDBName, "\\messaging_master.db");
    48 		_LIT(KMainDummyDBName, "\\messaging_master.db");
    49 		_LIT(KMessagingDBName, "\\messaging.db");
    49 		_LIT(KMessagingDBName, "\\messaging.db");
    50 	#else
    50 	#else
    51 		_LIT(KMainDummyDBName, "[1000484b]messaging_master.db");
    51 		_LIT(KMainDummyDBName, "[1000484B]messaging_master.db");
    52 		_LIT(KMessagingDBName, "[1000484b]messaging.db");
    52 		_LIT(KMessagingDBName, "[1000484B]messaging.db");
    53 	#endif
    53 	#endif
    54 
    54 
    55 	_LIT(KLogicalName, "DB");
    55 	_LIT(KLogicalName, "DB");
    56 	_LIT(KComma, ", ");
    56 	_LIT(KComma, ", ");
    57 	_LIT(KDelimiter, " ;");
    57 	_LIT(KDelimiter, " ;");
  1237 		User::Leave(KErrNotFound);
  1237 		User::Leave(KErrNotFound);
  1238 		}
  1238 		}
  1239 
  1239 
  1240 	//Get the entry from the statement
  1240 	//Get the entry from the statement
  1241 	aEntry = CMsvEntryFreePool::Instance()->EntryL();
  1241 	aEntry = CMsvEntryFreePool::Instance()->EntryL();
       
  1242 	CleanupStack::PushL(cacheEntry);
  1242 	aEntry->Entry().iId = aId;
  1243 	aEntry->Entry().iId = aId;
  1243 	
  1244 	
  1244 	LoadEntryFromStatementL(getStmt, EGetEntry, aVisibleParentEntryId, *aEntry);
  1245 	LoadEntryFromStatementL(getStmt, EGetEntry, aVisibleParentEntryId, *aEntry);
  1245 	
  1246 	
  1246 	//We do not return non-standard visible folders from a non-current drive's database.
  1247 	//We do not return non-standard visible folders from a non-current drive's database.
  1281 	// Mask iRelatedId if it is a non-standard id.
  1282 	// Mask iRelatedId if it is a non-standard id.
  1282 	if(!IsStandardId(aEntry->Entry().iRelatedId))
  1283 	if(!IsStandardId(aEntry->Entry().iRelatedId))
  1283 		{
  1284 		{
  1284 		aEntry->Entry().iRelatedId = MaskTMsvId(driveId, aEntry->Entry().iRelatedId);
  1285 		aEntry->Entry().iRelatedId = MaskTMsvId(driveId, aEntry->Entry().iRelatedId);
  1285 		}
  1286 		}
  1286 	
  1287 
       
  1288 	CleanupStack::Pop(cacheEntry);
  1287 	CleanupStack::PopAndDestroy(2); //getStmt, queryBuf
  1289 	CleanupStack::PopAndDestroy(2); //getStmt, queryBuf
  1288 	}
  1290 	}
  1289 
  1291 
  1290 
  1292 
  1291 
  1293 
  1343 			continue;
  1345 			continue;
  1344 			}
  1346 			}
  1345 			
  1347 			
  1346 		TMsvId aVisibleParentEntryId;
  1348 		TMsvId aVisibleParentEntryId;
  1347 		CMsvCacheEntry *cacheEntry = CMsvEntryFreePool::Instance()->EntryL();
  1349 		CMsvCacheEntry *cacheEntry = CMsvEntryFreePool::Instance()->EntryL();
       
  1350 		CleanupStack::PushL(cacheEntry);
  1348 		if(!IsStandardId(aParentId))
  1351 		if(!IsStandardId(aParentId))
  1349 			{
  1352 			{
  1350 			aParentId = MaskTMsvId(driveId, aParentId);
  1353 			aParentId = MaskTMsvId(driveId, aParentId);
  1351 			}
  1354 			}
  1352 		cacheEntry->Entry().iParentId = aParentId;
  1355 		cacheEntry->Entry().iParentId = aParentId;
  1370 			cacheEntry->Entry().iRelatedId = MaskTMsvId(driveId, cacheEntry->Entry().iRelatedId);
  1373 			cacheEntry->Entry().iRelatedId = MaskTMsvId(driveId, cacheEntry->Entry().iRelatedId);
  1371 			}
  1374 			}
  1372 	
  1375 	
  1373 		//Add the child entry to the array given
  1376 		//Add the child entry to the array given
  1374 		aChildArray.AppendL(cacheEntry);
  1377 		aChildArray.AppendL(cacheEntry);
  1375 		}
  1378 		CleanupStack::Pop(cacheEntry);
  1376 	
  1379 		}
  1377 	CleanupStack::PopAndDestroy(2); //getStmt, queryBuf
  1380 	CleanupStack::PopAndDestroy(2); //getStmt, queryBuf
  1378 	}
  1381 	}
  1379 
  1382 
  1380 
  1383 
  1381 
  1384 
  1508 		  	{
  1511 		  	{
  1509 			continue;
  1512 			continue;
  1510 			}
  1513 			}
  1511 		
  1514 		
  1512 		CMsvCacheEntry* cacheEntry = CMsvEntryFreePool::Instance()->EntryL();
  1515 		CMsvCacheEntry* cacheEntry = CMsvEntryFreePool::Instance()->EntryL();
       
  1516 		CleanupStack::PushL(cacheEntry);
  1513 		if(!IsStandardId(aParentId))
  1517 		if(!IsStandardId(aParentId))
  1514 			{
  1518 			{
  1515 			aParentId = MaskTMsvId(driveId, aParentId);
  1519 			aParentId = MaskTMsvId(driveId, aParentId);
  1516 			}
  1520 			}
  1517 		cacheEntry->Entry().iParentId = aParentId;
  1521 		cacheEntry->Entry().iParentId = aParentId;
  1561 			cacheEntry->Entry().iRelatedId = MaskTMsvId(driveId, cacheEntry->Entry().iRelatedId);
  1565 			cacheEntry->Entry().iRelatedId = MaskTMsvId(driveId, cacheEntry->Entry().iRelatedId);
  1562 			}
  1566 			}
  1563 		
  1567 		
  1564 		//Add the child entry to the array given
  1568 		//Add the child entry to the array given
  1565 		aChildArray.AppendL(cacheEntry);
  1569 		aChildArray.AppendL(cacheEntry);
       
  1570 		CleanupStack::Pop(cacheEntry);
  1566 		}
  1571 		}
  1567 	CleanupStack::PopAndDestroy(2);		// condGetChildrenStmnt,queryBuf
  1572 	CleanupStack::PopAndDestroy(2);		// condGetChildrenStmnt,queryBuf
  1568 	}
  1573 	}
  1569 
  1574 
  1570 
  1575 
  2402 		User::Leave(KErrNotFound);
  2407 		User::Leave(KErrNotFound);
  2403 		}
  2408 		}
  2404 
  2409 
  2405 	//Get the entry from the statement
  2410 	//Get the entry from the statement
  2406 	aEntry = CMsvEntryFreePool::Instance()->EntryL();
  2411 	aEntry = CMsvEntryFreePool::Instance()->EntryL();
       
  2412 	CleanupStack::PushL(aEntry);
  2407 	aEntry->Entry().iId = aId;
  2413 	aEntry->Entry().iId = aId;
  2408 	LoadEntryFromStatementL(iStatement[EGetEntry], EGetEntry, aVisibleParentEntryId, *aEntry);
  2414 	LoadEntryFromStatementL(iStatement[EGetEntry], EGetEntry, aVisibleParentEntryId, *aEntry);
  2409 
  2415 	CleanupStack::Pop(aEntry);
  2410 	//Reset the RSqlStatement
  2416 	//Reset the RSqlStatement
  2411 	User::LeaveIfError(iStatement[EGetEntry].Reset());
  2417 	User::LeaveIfError(iStatement[EGetEntry].Reset());
  2412 	}
  2418 	}
  2413 
  2419 
  2414 
  2420 
  2430 
  2436 
  2431 	while(KSqlAtRow == iStatement[EGetChildEntries].Next())
  2437 	while(KSqlAtRow == iStatement[EGetChildEntries].Next())
  2432 		{
  2438 		{
  2433 		TMsvId aVisibleParentEntryId;
  2439 		TMsvId aVisibleParentEntryId;
  2434 		CMsvCacheEntry *cacheEntry = CMsvEntryFreePool::Instance()->EntryL();
  2440 		CMsvCacheEntry *cacheEntry = CMsvEntryFreePool::Instance()->EntryL();
       
  2441 		CleanupStack::PushL(cacheEntry);
  2435 		cacheEntry->Entry().iParentId = aParentId;
  2442 		cacheEntry->Entry().iParentId = aParentId;
  2436 		LoadEntryFromStatementL(iStatement[EGetChildEntries], EGetChildEntries, aVisibleParentEntryId, *cacheEntry);
  2443 		LoadEntryFromStatementL(iStatement[EGetChildEntries], EGetChildEntries, aVisibleParentEntryId, *cacheEntry);
  2437 		//Add the child entry to the array given
  2444 		//Add the child entry to the array given
  2438 		aChildArray.AppendL(cacheEntry);
  2445 		aChildArray.AppendL(cacheEntry);
       
  2446 		CleanupStack::Pop(cacheEntry);
  2439 		}
  2447 		}
  2440 
  2448 
  2441 	//Reset the RSqlStatement
  2449 	//Reset the RSqlStatement
  2442 	User::LeaveIfError(iStatement[EGetChildEntries].Reset());
  2450 	User::LeaveIfError(iStatement[EGetChildEntries].Reset());
  2443 	}
  2451 	}
  2509 	BindIntL(condGetChildrenStmnt, index, aParentId);
  2517 	BindIntL(condGetChildrenStmnt, index, aParentId);
  2510 
  2518 
  2511 	while(KSqlAtRow == condGetChildrenStmnt.Next())
  2519 	while(KSqlAtRow == condGetChildrenStmnt.Next())
  2512 		{
  2520 		{
  2513 		CMsvCacheEntry* cacheEntry = CMsvEntryFreePool::Instance()->EntryL();
  2521 		CMsvCacheEntry* cacheEntry = CMsvEntryFreePool::Instance()->EntryL();
       
  2522 		CleanupStack::PushL(cacheEntry);
  2514 		cacheEntry->Entry().iParentId = aParentId;
  2523 		cacheEntry->Entry().iParentId = aParentId;
  2515 
  2524 
  2516 		index = 0;
  2525 		index = 0;
  2517 		cacheEntry->Entry().iId = ColumnInt(condGetChildrenStmnt, index);
  2526 		cacheEntry->Entry().iId = ColumnInt(condGetChildrenStmnt, index);
  2518 		cacheEntry->Entry().iServiceId = ColumnInt(condGetChildrenStmnt, ++index);
  2527 		cacheEntry->Entry().iServiceId = ColumnInt(condGetChildrenStmnt, ++index);
  2536 		cacheEntry->iDetailsBuffer = ColumnTextL(condGetChildrenStmnt, ++index); 	
  2545 		cacheEntry->iDetailsBuffer = ColumnTextL(condGetChildrenStmnt, ++index); 	
  2537 		cacheEntry->Entry().iDetails.Set(*cacheEntry->iDetailsBuffer);
  2546 		cacheEntry->Entry().iDetails.Set(*cacheEntry->iDetailsBuffer);
  2538 		
  2547 		
  2539 		//Add the child entry to the array given
  2548 		//Add the child entry to the array given
  2540 		aChildArray.AppendL(cacheEntry);
  2549 		aChildArray.AppendL(cacheEntry);
       
  2550 		CleanupStack::Pop(cacheEntry);
  2541 		}
  2551 		}
  2542 	CleanupStack::PopAndDestroy(2);		// condGetChildrenStmnt,queryBuf
  2552 	CleanupStack::PopAndDestroy(2);		// condGetChildrenStmnt,queryBuf
  2543 	}
  2553 	}
  2544 
  2554 
  2545 
  2555