44
|
1 |
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
//
|
|
16 |
|
|
17 |
//system include
|
|
18 |
#include <mpbutil.h>
|
|
19 |
//user include
|
|
20 |
#include "testltsyphbkwrite.h"
|
|
21 |
//const define
|
|
22 |
const TUint8 KTypeOfNumber=0x81;
|
|
23 |
|
|
24 |
CTestLtsyPhbkWrite::CTestLtsyPhbkWrite(CTestLtsyModel& aTestModel)
|
|
25 |
: CTestLtsyPhoneStoreBase(aTestModel)
|
|
26 |
{
|
|
27 |
|
|
28 |
}
|
|
29 |
|
|
30 |
CTestLtsyPhbkWrite::~CTestLtsyPhbkWrite()
|
|
31 |
{
|
|
32 |
}
|
|
33 |
|
|
34 |
CTestLtsyPhbkWrite* CTestLtsyPhbkWrite::NewLC(CTestLtsyModel& aTestModel)
|
|
35 |
{
|
|
36 |
CTestLtsyPhbkWrite* self = new (ELeave)CTestLtsyPhbkWrite(aTestModel);
|
|
37 |
CleanupStack::PushL(self);
|
|
38 |
self->ConstructL();
|
|
39 |
return self;
|
|
40 |
}
|
|
41 |
|
|
42 |
CTestLtsyPhbkWrite* CTestLtsyPhbkWrite::NewL(CTestLtsyModel& aTestModel)
|
|
43 |
{
|
|
44 |
CTestLtsyPhbkWrite* self=CTestLtsyPhbkWrite::NewLC(aTestModel);
|
|
45 |
CleanupStack::Pop(self);
|
|
46 |
return self;
|
|
47 |
}
|
|
48 |
|
|
49 |
void CTestLtsyPhbkWrite::ConstructL()
|
|
50 |
{
|
|
51 |
|
|
52 |
}
|
|
53 |
|
|
54 |
TVerdict CTestLtsyPhbkWrite::doTestStepPreambleL()
|
|
55 |
{
|
|
56 |
INFO_PRINTF1(_L("CTestLtsyPhbkWrite::doTestStepPreambleL called"));
|
|
57 |
SetTestStepResult(EPass);
|
|
58 |
return TestStepResult();
|
|
59 |
}
|
|
60 |
|
|
61 |
TVerdict CTestLtsyPhbkWrite::doTestStepL()
|
|
62 |
{
|
|
63 |
INFO_PRINTF1(_L("CTestLtsyPhbkWrite::doTestStepL called"));
|
|
64 |
TInt index = 10;
|
|
65 |
TRAPD(err,WriteEntryL(index));
|
|
66 |
if(err != KErrNone)
|
|
67 |
{
|
|
68 |
INFO_PRINTF2(_L("The error was returned %d!! when write phonebook"),err);
|
|
69 |
SetTestStepResult(EFail);
|
|
70 |
}
|
|
71 |
return TestStepResult();
|
|
72 |
}
|
|
73 |
|
|
74 |
TVerdict CTestLtsyPhbkWrite::doTestStepPostambleL()
|
|
75 |
{
|
|
76 |
INFO_PRINTF1(_L("CTestLtsyPhbkWrite::doTestStepPostambleL called"));
|
|
77 |
return TestStepResult();
|
|
78 |
}
|
|
79 |
|
|
80 |
void CTestLtsyPhbkWrite::WriteEntryL(TInt aIndex)
|
|
81 |
{
|
|
82 |
TRequestStatus status;
|
|
83 |
TBuf8<800> pbData; // Client reserved space for phonebook data
|
|
84 |
TInt ret;
|
|
85 |
|
|
86 |
_LIT16(KTel,"123456%03d");
|
|
87 |
_LIT16(KText,"TelNo %03d");
|
|
88 |
TBuf16<20> text(KTel), number(KText);
|
|
89 |
|
|
90 |
CPhoneBookBuffer* pbBuffer = new(ELeave) CPhoneBookBuffer(); // used to write phonebook data
|
|
91 |
CleanupStack::PushL(pbBuffer);
|
|
92 |
pbBuffer->Set(&pbData); // Set it to point to the Client buffer
|
|
93 |
pbBuffer->AddNewEntryTag();
|
|
94 |
// convert number into TLV format and append it to allocated buffer
|
|
95 |
TInt index = aIndex;
|
|
96 |
ret = pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBAdnIndex,(TUint16)index);
|
|
97 |
if( ret != KErrNone )
|
|
98 |
{
|
|
99 |
CleanupStack::PopAndDestroy();
|
|
100 |
SetTestStepResult(EFail);
|
|
101 |
}
|
|
102 |
number.Format(KTel(), index);
|
|
103 |
ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBNumber, number);
|
|
104 |
// ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBNewEntry, number);
|
|
105 |
if( ret != KErrNone )
|
|
106 |
{
|
|
107 |
CleanupStack::PopAndDestroy();
|
|
108 |
SetTestStepResult(EFail);
|
|
109 |
}
|
|
110 |
// convert number type into TLV format and append it to allocated buffer
|
|
111 |
TUint8 tonNpi=KTypeOfNumber;
|
|
112 |
ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBTonNpi, tonNpi);
|
|
113 |
if(ret!=KErrNone)
|
|
114 |
{
|
|
115 |
CleanupStack::PopAndDestroy();
|
|
116 |
SetTestStepResult(EFail);
|
|
117 |
}
|
|
118 |
|
|
119 |
text.Format(KText(), index);
|
|
120 |
// convert text into TLV format and append it to allocated buffer
|
|
121 |
ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBText, text);
|
|
122 |
if(ret != KErrNone)
|
|
123 |
{
|
|
124 |
CleanupStack::PopAndDestroy();
|
|
125 |
SetTestStepResult(EFail);
|
|
126 |
}
|
|
127 |
PhoneBookStore().Write(status, pbData,index);
|
|
128 |
User::WaitForRequest(status);
|
|
129 |
TInt r=status.Int();
|
|
130 |
INFO_PRINTF2(_L("Write() request status = %d"),r);
|
|
131 |
CleanupStack::PopAndDestroy();
|
|
132 |
}
|
|
133 |
|
|
134 |
// end of file
|