/**
Set up the CCntSqlStatement objects held by the class.
*/
void CPplGroupsTable::ConstructL()
{
// Statement types
TCntSqlStatementType insertType(EInsert, KSqlContactGroupTableName);
TCntSqlStatementType selectType(ESelect, KSqlContactGroupTableName);
TCntSqlStatementType updateType(EUpdate, KSqlContactGroupTableName);
TCntSqlStatementType deleteType(EDelete, KSqlContactGroupTableName);
TCntSqlStatementType countContactsType(ESelect, KSqlContactTableName);
// Where clauses
// sizes of the clauses
const TInt KWhereGroupClauseBufSize(KGroupContactGroupId().Size() +
KWhereStringEqualsStringFormatText().Size() + KGroupContactGroupIdParam().Size() );
const TInt KWhereMemberClauseBufSize(KGroupContactGroupMemberId().Size() +
KWhereStringEqualsStringFormatText().Size() + KGroupContactGroupMemberIdParam().Size() );
const TInt KWhereOrClauseBufSize(KWhereGroupClauseBufSize + KSqlOr().Size() + KWhereMemberClauseBufSize);
// for WHERE contact_group_id = [contact id value]
HBufC* whereGroupIdClause = HBufC::NewLC(KWhereGroupClauseBufSize);
whereGroupIdClause->Des().AppendFormat(KWhereStringEqualsStringFormatText,
&KGroupContactGroupId, &KGroupContactGroupIdParam );
// for WHERE contact_group_member_id = [contact id value]
HBufC* whereMemberIdClause = HBufC::NewLC(KWhereMemberClauseBufSize);
whereMemberIdClause->Des().AppendFormat(KWhereStringEqualsStringFormatText,
&KGroupContactGroupMemberId, &KGroupContactGroupMemberIdParam );
// for WHERE contact_group_id = [contact id value]
// OR contact_group_member_id = [contact id value]
HBufC* whereGroupOrMemberIdClause = HBufC::NewLC(KWhereOrClauseBufSize);
TPtr whereGroupOrMemberIdClausePtr = whereGroupOrMemberIdClause->Des();
whereGroupOrMemberIdClausePtr.AppendFormat(KWhereStringEqualsStringFormatText,
&KGroupContactGroupId, &KGroupContactGroupIdParam);
whereGroupOrMemberIdClausePtr.Append(KSqlOr);
whereGroupOrMemberIdClausePtr.AppendFormat(KWhereStringEqualsStringFormatText,
&KGroupContactGroupMemberId, &KGroupContactGroupMemberIdParam);
// for WHERE contact_id = [contact_id]
HBufC* whereContactIdClause = HBufC::NewLC(KWhereGroupClauseBufSize);
whereContactIdClause->Des().AppendFormat(KWhereStringEqualsStringFormatText,
&KContactId, &KContactIdParam );
// INSERT
// insert group-member relationships
// For a statement in the following format:
// INSERT INTO groups
// (group_id, contact_group_id, contact_group_member_id)
// VALUES (NULL, [contact group id value], [contact group member id value]);
//
iInsertStmnt = TSqlProvider::GetSqlStatementL(insertType);
iInsertStmnt->SetParamL(KGroupContactGroupId(), KGroupContactGroupIdParam());
iInsertStmnt->SetParamL(KGroupContactGroupMemberId(), KGroupContactGroupMemberIdParam());
// SELECT
// select group id
// For a statement in the following format:
// SELECT contact_group_id FROM groups
// WHERE contact_group_member_id = [contact id value];
//
iSelectGroupsStmnt = TSqlProvider::GetSqlStatementL(selectType);
iSelectGroupsStmnt->SetParamL(KGroupContactGroupId(), KNullDesC() );
iSelectGroupsStmnt->SetConditionL(*whereMemberIdClause);
// select member id
// For a statement in the following format:
// SELECT contact_group_member_id FROM groups
// WHERE contact_group_id = [contact id value];
//
iSelectMembersStmnt = TSqlProvider::GetSqlStatementL(selectType);
iSelectMembersStmnt->SetParamL(KGroupContactGroupMemberId(), KNullDesC() );
iSelectMembersStmnt->SetConditionL(*whereGroupIdClause);
// DELETE
// delete all where group or member equals id
// For a statement in the following format:
// DELETE FROM groups WHERE contact_group_id = [contact id value]
// OR contact_group_member_id = [contact id value];
//
iDeleteStmnt = TSqlProvider::GetSqlStatementL(deleteType);
iDeleteStmnt->SetConditionL(*whereGroupOrMemberIdClause);
// SELECT
// SELECt count(*) FROM contact WHERE contact_id = [contact_id]
iCountContactsStmnt = TSqlProvider::GetSqlStatementL(countContactsType);
iCountContactsStmnt->SetParamL(KSqlCount, KSpace);
iCountContactsStmnt->SetConditionL(*whereContactIdClause);
CleanupStack::PopAndDestroy(4, whereGroupIdClause); // and whereContactIdClause, whereMemberIdClause, whereGroupOrMemberIdClause
}
/**
@SYMTestCaseID UIF-ETUL-0009
@SYMREQ 7736
@SYMTestCaseDesc Test to Parse for URI's, Email Addresses, Phone Numbers and URL's in a file and to verify them
@SYMTestPriority High
@SYMTestStatus Implemented
@SYMTestActions Constructs CTulAddressStringTokenizer object with CTulAddressStringTokenizer::EFindItemSearchMailAddressBin \n
which parses the given string and creates an item array consisting of all the Email addresses\n
API Calls:\n
CTulAddressStringTokenizer::NewL(const TDesC& aText, TInt aSearchCases);\n
CTulAddressStringTokenizer::Item(SFoundItem& aItem); \n
CTulAddressStringTokenizer::NextItem(SFoundItem& aItem); \n
@SYMTestExpectedResults The test checks whether
1. Phone numbers, Email addresses, URL's and URI's parsed by CTulAddressStringTokenizer are the correct ones.
*/
void CT_AddressStringTokenizerStep::ParseURIFileL()
{
INFO_PRINTF1(_L("Test begins"));
__UHEAP_MARK;
//load test case text to string
RFs rfs;
User::LeaveIfError(rfs.Connect());
CleanupClosePushL(rfs);
_LIT(KParesTextFile, "z:\\system\\data\\addressstringtokenizertestappdata.txt");
_LIT(KParesTextFileRef, "z:\\system\\data\\addressstringtokenizertestappdataref.txt");
RFile file;
HBufC* fullBuf = HBufC::NewMaxLC(KFullBufSize);
TPtr fullBufPtr = fullBuf->Des();
fullBufPtr = KNullDesC;
TFileText reader;
TBuf<KReadBufSize> fileBuffer;
if ((file.Open(rfs, KParesTextFile, EFileStreamText|EFileRead|EFileShareAny)) == KErrNone)
{
CleanupClosePushL(file);
// use TFileText for reading file. There is probably better ways to do this tho.
reader.Set(file);
if (reader.Seek(ESeekStart))
{
INFO_PRINTF1(_L("File corrupted"));
User::Leave(KErrGeneral); // not cleaning up properly
}
while (!reader.Read(fileBuffer))
{
fullBufPtr.Append(fileBuffer);
fullBufPtr.Append('\n');
}
CleanupStack::Pop(&file);
file.Close();
}
else
{
INFO_PRINTF1(_L("z:\\system\\data\\addressstringtokenizertestappdata.txt not found"));
User::Leave(KErrNotFound);
}
if (file.Open(rfs, KParesTextFileRef, EFileStreamText|EFileRead|EFileShareAny) == KErrNone)
{
CleanupClosePushL(file);
// use TFileText for reading file. There is probably better way to do this tho.
reader.Set(file);
if (reader.Seek(ESeekStart))
{
INFO_PRINTF1(_L("File corrupted"));
User::Leave(KErrGeneral); // not cleaning up properly
}
}
else
{
INFO_PRINTF1(_L("z:\\system\\data\\addressstringtokenizertestappdataref.txt not found"));
User::Leave(KErrNotFound);
}
INFO_PRINTF1(_L("Start searching..."));
// Create an instance of Address String Tokenizer and search for URL's.
CTulAddressStringTokenizer* addressString = CTulAddressStringTokenizer::NewL(fullBufPtr, CTulAddressStringTokenizer::EFindItemSearchURLBin);
TestAddressStringTokenizers(addressString, reader, fullBufPtr);
delete addressString;
// find phone numbers from same text
addressString = CTulAddressStringTokenizer::NewL(fullBufPtr, CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin);
TestAddressStringTokenizers(addressString, reader, fullBufPtr);
// test do new search with same instance
TInt count = addressString->DoNewSearchL(fullBufPtr, CTulAddressStringTokenizer::EFindItemSearchMailAddressBin);
TEST(count > 0);
TestAddressStringTokenizers(addressString, reader, fullBufPtr);
delete addressString;
//.........这里部分代码省略.........
//----------------------------------------------
// execute menu item command
//----------------------------------------------
Bool TLMenu::TMenuController::ExecuteMenuItem(TRefRef MenuItemRef)
{
TPtr<TMenuItem> pMenuItem = GetMenuItem(MenuItemRef);
if ( !pMenuItem )
{
TLDebug_Break("No such menu item");
return FALSE;
}
// get command of menu item
TRefRef MenuCommand = pMenuItem->GetMenuCommand();
TRefRef AudioRef = pMenuItem->GetAudioRef();;
// open-menu command
if ( MenuCommand == "Open" )
{
// Already has a queued command?
if(m_QueuedCommand.GetRef().IsValid())
return FALSE;
// Queue up the command.
m_QueuedCommand.SetRef(MenuCommand);
m_QueuedCommand.SetTypeRef(pMenuItem->GetNextMenu());
}
else if ( MenuCommand == "Close" )
{
// Already has a queued command?
if(m_QueuedCommand.GetRef().IsValid())
return FALSE;
// Queue up the command.
m_QueuedCommand.SetRef(MenuCommand);
}
else
{
// do non standard command
if ( !ExecuteCommand( MenuCommand, pMenuItem->GetData() ) )
return FALSE;
}
// Valid audio to play?
// Create menu audio for command execution
// gr: this should go in menu renderer code, not menu logic code
if(AudioRef.IsValid())
{
TLMessaging::TMessage Message(TLCore::InitialiseRef);
Message.ExportData("Asset", AudioRef);
Message.ExportData("Play", TRUE);
Message.ExportData("RateOfDecay", 0.0f); // Make 2D
Message.ExportData("MinRange", 100000.0f);
Message.ExportData("MaxRange", 100000.0f);
TLAudio::g_pAudiograph->StartAudio(MenuCommand, AudioRef);
}
// publish that command has been executed
OnMenuItemExecuted( MenuCommand, pMenuItem->GetData() );
return TRUE;
}
TVerdict CHashIncrementalHashWithCopyStep::doTestStepL()
{
if (TestStepResult()==EPass)
{
//Assume faliure, unless all is successful
SetTestStepResult(EFail);
INFO_PRINTF1(_L("*** Hash - Incremental Hash with Copy ***"));
INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
TVariantPtrC algorithmUid;
TVariantPtrC operationModeUid;
TPtrC sourcePath;
TPtrC expectedHash;
//Extract the Test Case ID parameter from the specified INI file
if(!GetStringFromConfig(ConfigSection(),KConfigAlgorithmUid,algorithmUid) ||
!GetStringFromConfig(ConfigSection(),KConfigOperationMode,operationModeUid) ||
!GetStringFromConfig(ConfigSection(),KConfigSourcePath,sourcePath) ||
!GetStringFromConfig(ConfigSection(),KConfigExHashHmacValue,expectedHash))
{
ERR_PRINTF1(_L("** Error: Failed to Load Configuration Parameters **"));
SetTestStepResult(EFail);
}
else
{
//Create a pointer for the Hash Implementation Object
CHash* hashImpl = NULL;
//Retrieve a Hash Factory Object
TRAPD(err,CHashFactory::CreateHashL(hashImpl,
algorithmUid,
operationModeUid,
NULL,
NULL));
if(hashImpl && (err == KErrNone))
{
//Push the Hash Implementation Object onto the Cleanup Stack
CleanupStack::PushL(hashImpl);
RFs fsSession;
//Create a connection to the file server
err = fsSession.Connect();
if(err != KErrNone)
{
ERR_PRINTF2(_L("*** Error: File Server Connection - %d ***"), err);
SetTestStepResult(EFail);
}
else
{
RFile sourceFile;
CleanupClosePushL(sourceFile);
//Open the specified source file
err = sourceFile.Open(fsSession,sourcePath, EFileRead);
if(err != KErrNone)
{
ERR_PRINTF2(_L("*** Error: Opening Source File - %d ***"), err);
SetTestStepResult(EFail);
}
else
{
TInt sourceLength = 0;
TInt readPosition = 0;
TInt readIncrement = 0;
TBool hashComplete = EFalse;
TBool hashCopied = EFalse;
TPtrC8 hashStr;
CHash* hashCopyImpl = NULL;
User::LeaveIfError(sourceFile.Size(sourceLength));
//Divide the total size of the source file up into individual equal sized blocks to read
//over several increments
readIncrement = sourceLength/KDataReadBlocks;
do
{
//Create a heap based descriptor to store the data
HBufC8* sourceData = HBufC8::NewL(readIncrement);
CleanupStack::PushL(sourceData);
TPtr8 sourcePtr = sourceData->Des();
//Read in a block of data from the source file from the current position
err = sourceFile.Read(readPosition,sourcePtr,readIncrement);
//Update the read position by adding the number of bytes read
readPosition += readIncrement;
if(readPosition == readIncrement)
{
//Read in the first block from the data file into the Hash implementation object
//.........这里部分代码省略.........
请发表评论