|
1 // Copyright (c) 2001-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 #ifndef __SIMPHBKSTORE_H_ |
|
17 #define __SIMPHBKSTORE_H_ |
|
18 |
|
19 /** |
|
20 * @file |
|
21 * |
|
22 * Contains the class definitions required for the Phonebook Store. |
|
23 * @internalAll |
|
24 */ |
|
25 |
|
26 #include <etelmm.h> |
|
27 #include <et_phone.h> |
|
28 #include <mpbutil.h> |
|
29 #include "csimtimer.h" |
|
30 #include "CSimPhone.h" |
|
31 #include "CSimPhoneSecurity.h" |
|
32 |
|
33 const TInt KPhBkMaxAlphaTagSize=241; |
|
34 const TInt KPhBkMaxTelNumSize=100; |
|
35 |
|
36 /** |
|
37 * The main Phonebook Store class which simulates a Phonebook Store. |
|
38 */ |
|
39 class CSimPhone; |
|
40 class CTestConfigSection; |
|
41 class CTestConfigItem; |
|
42 class CSimPhBkStore : public CSimPhone, public MTimerCallBack |
|
43 { |
|
44 public: |
|
45 static CSimPhBkStore* NewL(CSimPhone* aPhone, const TDesC8& aName, TInt aMaxNumSlots, TInt aMaxNumLen, TInt aMaxTextLen); |
|
46 CSimPhBkStore(CSimPhone* aPhone); |
|
47 ~CSimPhBkStore(); |
|
48 |
|
49 static void ClosePhone(TAny* aObj); |
|
50 virtual CTelObject::TReqMode ReqModeL(const TInt aIpc); |
|
51 // MTelObjectTSY pure virtual |
|
52 virtual TInt RegisterNotification(const TInt aIpc); |
|
53 virtual TInt DeregisterNotification(const TInt aIpc); |
|
54 virtual void Init(); |
|
55 virtual CTelObject* OpenNewObjectByNameL(const TDesC& aName); |
|
56 virtual CTelObject* OpenNewObjectL(TDes& aNewName); |
|
57 virtual TInt NumberOfSlotsL(const TInt aIpc); |
|
58 virtual TInt CancelService(const TInt aIpc,const TTsyReqHandle aTsyReqHandle); |
|
59 |
|
60 // MSubSessionExtBaseTSY pure virtual |
|
61 virtual TInt ExtFunc(const TTsyReqHandle aTsyReqHandle,const TInt aIpc,const TDataPackage& aPackage); |
|
62 |
|
63 // Other public functions. |
|
64 void PopulateStoreFromConfigFileL(); |
|
65 void PopulatePhBkStoreInfo(RMobilePhoneStore::TMobilePhoneStoreInfoV1* aStoreInfo); |
|
66 |
|
67 //coverity[bad_override] |
|
68 TPtrC8 Name(); |
|
69 TInt UsedEntries(); |
|
70 TInt MaxSlots(); |
|
71 protected: |
|
72 void ConstructL(const TDesC8& aName, TInt aMaxNumSlots, TInt aMaxNumLen, TInt aMaxTextLen); |
|
73 |
|
74 private: |
|
75 TInt GetInfo(TTsyReqHandle aReqHandle, TDes8* aPckg); |
|
76 TInt Read(TTsyReqHandle aReqHandle, TDes8* aPckg1, TDes8* aPckg2); |
|
77 TInt Write(TTsyReqHandle aReqHandle,TDes8* aPckg1, TDes8* aPckg2); |
|
78 TInt Delete(TTsyReqHandle aReqHandle,TDes8* aPckg); |
|
79 TInt DeleteAll(TTsyReqHandle aReqHandle); |
|
80 TInt NotifyStoreEvent(TTsyReqHandle aReqHandle,TDes8* aPckg1,TDes8* aPckg2); |
|
81 void NotifyStoreEventCancel(); |
|
82 |
|
83 enum TStoreEvent // < Store event identifier. |
|
84 { |
|
85 EStoreEventNoEvent, |
|
86 EStoreEventAdded, |
|
87 EStoreEventDeleted, |
|
88 EStoreEventChanged |
|
89 }; |
|
90 |
|
91 void StoreEvent(TStoreEvent aEvent,TInt aIndex); |
|
92 void DelayCompletion(TInt aDelayDuration,TTsyReqHandle aReqHandle); |
|
93 void DelayCompletion(TInt aDelayDuration,TTsyReqHandle aReqHandle,TStoreEvent aEvent,TInt aIndex); |
|
94 void TimerCallBack(TInt aId); |
|
95 TBool FindIpcErrorMatch(TInt& aError); |
|
96 const CTestConfigSection* CfgFile(); |
|
97 TInt GetPhBkEntry(const CTestConfigItem* aItem, TInt aTagIndex, TPtrC8& aPhonebookName, |
|
98 TInt& aIndex, TPtrC8& aTelNum, TPtrC8& aAlphaTag, TUint8& aNpiTon); |
|
99 void PopulateOOBWrite(); |
|
100 void PopulateOOBDelete(); |
|
101 |
|
102 private: |
|
103 CPhoneBase* iDummyPhoneBaseRef; |
|
104 |
|
105 CSimPhone* iPhone; // < A pointer to the "owner" phone class. |
|
106 CSimTimer* iReqTimer; // < The timer used to delay request completions. |
|
107 CSimTimer* iOOBWriteTimer; // < The timer used to time an OOB store event. |
|
108 CSimTimer* iOOBDeleteTimer; // < The timer used to time an OOB delete event. |
|
109 |
|
110 TInt iPhBkMaxNumSlots; // < The maximum number of slots in this Phonebook store. |
|
111 TInt iPhBkMaxTelNumLen; // < The maximum size of a telephone number that can be stored in this Phonebook. |
|
112 TInt iPhBkMaxTextLen; // < The maximum size of an alpha tag that can be stored in this Phonebook. |
|
113 |
|
114 struct TPhBkStoreEntry |
|
115 { |
|
116 TBuf<KPhBkMaxAlphaTagSize> iAlphaTag; // < The phonebook entry's alpha tag. |
|
117 TUint8 iTonNpi; // < The phonebook entry's Type of Number and Number Plan Identifier. |
|
118 TBuf<KPhBkMaxTelNumSize> iTelNum; // < The phonebook entry's telephone number. |
|
119 }; |
|
120 |
|
121 TPhBkStoreEntry* iPhBkStoreEntries; // < A pointer to the Phonebook Store array. |
|
122 |
|
123 struct TPhBkError |
|
124 { |
|
125 TInt iCount; // < The IPC count of the request that is to be errored. |
|
126 TInt iError; // < The error number that must be used with that request. |
|
127 }; |
|
128 CArrayFixFlat<TPhBkError>* iPhBkError; // < Array of indicating where to simulate phonebook request errors. |
|
129 TInt iIpcCnt; // < The current count of IPC client requests. |
|
130 |
|
131 TBuf8<KMaxName> iPhBkStoreName; // < The name of the Phonebook Store. |
|
132 TUint iPhBkStoreCaps; // < The phone level caps of the PhBk Store |
|
133 |
|
134 CPhoneBookBuffer* iPhBkRwBuffer; // < The Phonebook read/write "streaming" class. |
|
135 |
|
136 TBool iEvOutstandingReq; // < A flag indicating an outstanding Phonebook Store notification request. |
|
137 TTsyReqHandle iEvReqHandle; // < The TSY request handle associated with an outstanding Phonebook Store notification request. |
|
138 TUint32* iEvEvent; // < The event flags associated with an outstanding Phonebook Store notification request. |
|
139 TInt* iEvIndex; // < The index value associated with an outstanding Phonebook Store notification request. |
|
140 |
|
141 TInt iPhBkIndividualPause; // < The pause value used to delay the completion of an individual Phonebook Store manipulation request. |
|
142 TInt iPhBkBatchPause; // < The pause value used to delay the completion of a batch Phonebook Store manipulation request. |
|
143 |
|
144 TTsyReqHandle iPendingReqCompletion; // < The TSY request handle for the request that is awaiting a timer event before completion. |
|
145 TStoreEvent iPendingEvent; // < The type of store event related to the request that is awaiting a timer event before completion. |
|
146 TInt iPendingIndex; // < The index related to the request that is awaiting a timer event before completion. |
|
147 |
|
148 TInt iPhBkOOBWriteDuration; // < The pause before the "out of band" write will be executed. |
|
149 TInt iPhBkOOBWriteIndex; // < The index number associated with the "out of band" write. |
|
150 TPhBkStoreEntry iPhBkOOBWrite; // < The phonebook entry to be written in the "out of band" write. |
|
151 |
|
152 TInt iPhBkOOBDeleteDuration; // < The pause before the "out of band" delete. |
|
153 TInt iPhBkOOBDeleteIndex; // < The inex number associated with the "out of band" delete. |
|
154 |
|
155 struct TTriggerEventIPC |
|
156 { |
|
157 TInt iIPC; |
|
158 TInt iIPCCnt; |
|
159 RMobilePhone::TMobilePhoneSecurityEvent iEvent; |
|
160 }; |
|
161 TTriggerEventIPC iTriggerEventIPC; // < If .iIPC is called .iIpcCnt times, .iEvent is triggered |
|
162 TInt iTriggerCnt; // < the counter used to count the number of times iTriggerEventIPC.iIpc has been called |
|
163 |
|
164 }; |
|
165 |
|
166 #endif |