|
1 /* |
|
2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: The base class for sim stores |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef VPBKSIMSTOREIMPL_CSTOREBASE_H |
|
21 #define VPBKSIMSTOREIMPL_CSTOREBASE_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <etelmm.h> |
|
26 #include "MVPbkSimCntStore.h" |
|
27 #include "VPbkSimStoreCommon.h" |
|
28 #include "MVPbkSimCommandObserver.h" |
|
29 #include "MVPbkSimContactObserver.h" |
|
30 #include <MVPbkSimPhoneObserver.h> |
|
31 #include "MSimRefreshObject.h" |
|
32 #include "METelStoreNotificationObserver.h" |
|
33 #include "MBtSapObserver.h" |
|
34 #include "CContactArray.h" // MContactArrayObserver |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 class RMobilePhoneStore; |
|
38 class MVPbkSimCommand; |
|
39 class CVPbkSimCommandStore; |
|
40 class CVPbkSimStateInformation; |
|
41 class CVPbkSimFieldTypeFilter; |
|
42 template <class MVPbkSimStoreObserver> class CVPbkAsyncObjectOperation; |
|
43 class CVPbkSimContactView; |
|
44 |
|
45 namespace VPbkSimStoreImpl { |
|
46 |
|
47 // DATA TYPES |
|
48 enum TStoreState |
|
49 { |
|
50 /// Store is not open |
|
51 EStoreNotOpen, |
|
52 /// Store is opening, init command is running |
|
53 EStoreIsOpening, |
|
54 /// Store is open |
|
55 EStoreOpen, |
|
56 /// Store is not available, e.g SAT refresh can cause this. |
|
57 EStoreNotAvailable |
|
58 }; |
|
59 |
|
60 // FUNCTION PROTOTYPES |
|
61 TUint32 ConvertETelStoreCaps( TUint32 aETelStoreCaps ); |
|
62 |
|
63 // FORWARD DECLARATIONS |
|
64 class CPhone; |
|
65 class CContactArray; |
|
66 class CETelStoreNotification; |
|
67 class CSimPhoneNumberIndex; |
|
68 class CSatRefreshNotifier; |
|
69 class TStoreParams; |
|
70 class CBtSapNotification; |
|
71 class CCompositeCmdBase; |
|
72 class CSharedViewArray; |
|
73 |
|
74 // CLASS DECLARATION |
|
75 |
|
76 /** |
|
77 * The base class for sim stores |
|
78 * |
|
79 */ |
|
80 NONSHARABLE_CLASS(CStoreBase) : public CBase, |
|
81 public MVPbkSimCntStore, |
|
82 public METelStoreNotificationObserver, |
|
83 public MSimRefreshObject, |
|
84 protected MVPbkSimCommandObserver, |
|
85 protected MContactArrayObserver, |
|
86 private MBtSapObserver |
|
87 { |
|
88 public: // Constructors and destructor |
|
89 |
|
90 /** |
|
91 * Destructor. |
|
92 */ |
|
93 virtual ~CStoreBase(); |
|
94 |
|
95 public: // New functions |
|
96 |
|
97 /** |
|
98 * Returns the ETel name of the store |
|
99 * @return Returns the ETel name of the store |
|
100 */ |
|
101 virtual const TDesC& ETelName() const = 0; |
|
102 |
|
103 /** |
|
104 * Returns the ETel base store |
|
105 * @return the ETel base store |
|
106 */ |
|
107 virtual RMobilePhoneStore& ETelStoreBase() = 0; |
|
108 |
|
109 /** |
|
110 * Returns the ETel phonebook information structure |
|
111 * Sub class must have the info as a member. |
|
112 * @return the ETel phonebook information structure |
|
113 */ |
|
114 virtual RMobilePhoneStore::TMobilePhoneStoreInfoV1& ETelStoreInfo() = 0; |
|
115 |
|
116 /** |
|
117 * Returns the ETel phonebook information structure package |
|
118 * Sub class must have the info and the info package as a member. |
|
119 * @return the ETel phonebook information structure package |
|
120 */ |
|
121 virtual TDes8& ETelStoreInfoPackge() = 0; |
|
122 |
|
123 /** |
|
124 * Creates a command to initialize store. |
|
125 * @param aObserver the observer for the command |
|
126 */ |
|
127 virtual MVPbkSimCommand* CreateInitCommandL( |
|
128 MVPbkSimCommandObserver& aObserver ) = 0; |
|
129 |
|
130 /** |
|
131 * Creates a command to update a contact from ETel |
|
132 * @param aSimIndex the index of the changed sim contact |
|
133 */ |
|
134 virtual MVPbkSimCommand* CreateUpdateCommandL( TInt aSimIndex ) = 0; |
|
135 |
|
136 /** |
|
137 * Creates a command to update a contact from ETel. Uses a reference to |
|
138 * the sim index. Client must update the index before the command is executed |
|
139 * @param aSimIndex a reference to the index of the changed sim contact |
|
140 */ |
|
141 virtual MVPbkSimCommand* CreateUpdateCommandUsingRefL( |
|
142 TInt& aSimIndexRef ) = 0; |
|
143 |
|
144 /** |
|
145 * Called after store has been refreshed due to SAT refresh. The store |
|
146 * implementation must completed the refresh with correct parameters. |
|
147 * |
|
148 * @param aSimRefreshCompletion the refresh to complete |
|
149 */ |
|
150 virtual void CompleteSATRefresh( |
|
151 MSimRefreshCompletion& aSimRefreshCompletion ) = 0; |
|
152 |
|
153 /** |
|
154 * Called in the beginning of the OpenL. The subclass should overwrite |
|
155 * this and not OpenL itself. |
|
156 * Default implelention returns ETrue |
|
157 * @return EFalse if the store can not be opened. The state |
|
158 * will be set to EStoreNotAvailable in that case |
|
159 */ |
|
160 virtual TBool AllowOpeningL(); |
|
161 |
|
162 /** |
|
163 * Returns the contact array |
|
164 * @return the contact array |
|
165 */ |
|
166 inline CContactArray& Contacts(); |
|
167 |
|
168 /** |
|
169 * Returns the ETel notification instance if the ETel store |
|
170 * supports notification. The ownership of the instance is not given. |
|
171 * @return the ETel notification reference or NULL |
|
172 */ |
|
173 inline CETelStoreNotification* ETelNotification() const; |
|
174 |
|
175 /** |
|
176 * Returns SIM state information |
|
177 * |
|
178 * @return SIM state information |
|
179 */ |
|
180 inline CVPbkSimStateInformation& SimStateInformation() const; |
|
181 |
|
182 public: // Functions from base classes |
|
183 |
|
184 /** |
|
185 * From MVPbkSimCntStore |
|
186 */ |
|
187 TVPbkSimStoreIdentifier Identifier() const; |
|
188 |
|
189 /** |
|
190 * From MVPbkSimCntStore |
|
191 * |
|
192 * Must be called from the sub class if it overwrites this. |
|
193 * It's better to overwrite AllowOpeningL than this. |
|
194 * Behavior: |
|
195 * EStoreNotOpen: starts constructing the store |
|
196 * EStoreIsOpening: does nothing |
|
197 * EStoreOpen: sends store ready event to observer |
|
198 * EStoreNotAvailable: sends store unavailable event to observer |
|
199 */ |
|
200 void OpenL( MVPbkSimStoreObserver& aObserver ); |
|
201 |
|
202 /** |
|
203 * From MVPbkSimCntStore |
|
204 * |
|
205 * Must be called from the sub class if it overwrites this |
|
206 */ |
|
207 void Close( MVPbkSimStoreObserver& aObserver ); |
|
208 |
|
209 /** |
|
210 * From MVPbkSimCntStore |
|
211 */ |
|
212 MVPbkSimCntView* CreateViewL( |
|
213 const RVPbkSimFieldTypeArray& aSortOrder, |
|
214 TVPbkSimViewConstructionPolicy aConstructionPolicy, |
|
215 const TDesC& aViewName, |
|
216 CVPbkSimFieldTypeFilter* aFilter ); |
|
217 |
|
218 /** |
|
219 * From MVPbkSimCntStore |
|
220 */ |
|
221 const TDesC8* AtL( TInt aSimIndex ); |
|
222 |
|
223 /** |
|
224 * From MVPbkSimCntStore |
|
225 */ |
|
226 virtual const MVPbkSimContact* ContactAtL( TInt aSimIndex ); |
|
227 |
|
228 /** |
|
229 * From MVPbkSimCntStore |
|
230 */ |
|
231 const CVPbkETelCntConverter& ContactConverter() const; |
|
232 |
|
233 /** |
|
234 * From MVPbkSimCntStore |
|
235 */ |
|
236 MVPbkSimStoreOperation* CreateMatchPhoneNumberOperationL( |
|
237 const TDesC& aPhoneNumber, TInt aMaxMatchDigits, |
|
238 MVPbkSimFindObserver& aObserver ); |
|
239 |
|
240 /** |
|
241 * From MVPbkSimCntStore |
|
242 */ |
|
243 MVPbkSimStoreOperation* CreateFindOperationL( |
|
244 const TDesC& aStringToFind, RVPbkSimFieldTypeArray& aFieldTypes, |
|
245 MVPbkSimFindObserver& aObserver ); |
|
246 |
|
247 /** |
|
248 * From MVPbkSimCntStore |
|
249 */ |
|
250 TInt SystemPhoneNumberMaxLength() const; |
|
251 |
|
252 /** |
|
253 * From METelStoreNotificationObserver |
|
254 */ |
|
255 TBool ETelStoreChanged( TInt aSimIndex, TUint32 aEvents ); |
|
256 |
|
257 /** |
|
258 * From METelStoreNotificationObserver |
|
259 */ |
|
260 TBool ETelStoreChangeError( TInt aError ); |
|
261 |
|
262 /** |
|
263 * From MContactArrayObserver |
|
264 */ |
|
265 void ContactAdded( MVPbkSimContact& aSimContact ); |
|
266 |
|
267 /** |
|
268 * From MContactArrayObserver |
|
269 */ |
|
270 void ContactRemoved( MVPbkSimContact& aRemovedContact ); |
|
271 |
|
272 /** |
|
273 * From MContactArrayObserver |
|
274 */ |
|
275 void ContactChanged( MVPbkSimContact& aOldContact, |
|
276 MVPbkSimContact& aNewContact ); |
|
277 |
|
278 protected: // New functions |
|
279 |
|
280 /** |
|
281 * Returns the phone subsession |
|
282 * @return the phone |
|
283 */ |
|
284 inline CPhone& Phone(); |
|
285 |
|
286 /** |
|
287 * Returns the command store |
|
288 * @return the command store |
|
289 */ |
|
290 inline CVPbkSimCommandStore& CommandStore(); |
|
291 |
|
292 /** |
|
293 * Returns the current state of the store |
|
294 * @return the current state of the store |
|
295 */ |
|
296 inline TStoreState CurrentState(); |
|
297 |
|
298 /** |
|
299 * Cancels all requests. Must be called from |
|
300 * the subclass destructor before closing any ETel sessions. |
|
301 */ |
|
302 void CancelRequests(); |
|
303 |
|
304 /** |
|
305 * Subclasses can call this to add an GetInfo command to the |
|
306 * command chain. |
|
307 * @param aCmdChain the command chain created by the subclass |
|
308 */ |
|
309 void AddGetInfoCmdToChainL( CCompositeCmdBase& aCmdChain ); |
|
310 |
|
311 /** |
|
312 * Resets this store |
|
313 */ |
|
314 void ResetStore(); |
|
315 |
|
316 /** |
|
317 * Starts initializing store |
|
318 */ |
|
319 void ConstructStoreL(); |
|
320 |
|
321 /** |
|
322 * Sends store ready event to all observers |
|
323 * Sets store state to EStoreOpen |
|
324 */ |
|
325 void SendStoreReadyEvent(); |
|
326 |
|
327 /** |
|
328 * Sends store unavailable event to all observers |
|
329 * Sets store state to EStoreNotOpen |
|
330 */ |
|
331 void SendStoreUnavailableEvent(); |
|
332 |
|
333 /** |
|
334 * Sends store error event to all observers |
|
335 * Sets store state to EStoreNotOpen |
|
336 */ |
|
337 void SendStoreErrorEvent(TInt aError); |
|
338 |
|
339 protected: // Functions from base classes |
|
340 |
|
341 /** |
|
342 * From MVPbkSimCommandObserver |
|
343 */ |
|
344 void CommandDone( MVPbkSimCommand& aCommand ); |
|
345 |
|
346 /** |
|
347 * From MVPbkSimCommandObserver |
|
348 */ |
|
349 void CommandError( MVPbkSimCommand& aCommand, TInt aError ); |
|
350 |
|
351 /** |
|
352 * From MSimRefreshObject |
|
353 */ |
|
354 void SimRefreshed( TUint32 aSimRefreshFlags, |
|
355 MSimRefreshCompletion& aSimRefreshCompletion ); |
|
356 |
|
357 /** |
|
358 * From MSimRefreshObject |
|
359 */ |
|
360 TBool AllowRefresh( TUint32 aSimRefreshFlags ); |
|
361 |
|
362 /** |
|
363 * From MSimRefreshObject |
|
364 */ |
|
365 TUint32 ElementaryFiles(); |
|
366 |
|
367 /** |
|
368 * From MBtSapObserver |
|
369 */ |
|
370 void BtSapActivated(); |
|
371 |
|
372 /** |
|
373 * From MBtSapObserver |
|
374 */ |
|
375 void BtSapDeactivated(); |
|
376 |
|
377 /** |
|
378 * From MBtSapObserver |
|
379 */ |
|
380 void BtSapNotificationError( TInt aError ); |
|
381 |
|
382 protected: // Construction |
|
383 |
|
384 /** |
|
385 * C++ constructor. |
|
386 * @param aParams store parameters |
|
387 */ |
|
388 CStoreBase( TStoreParams& aParams ); |
|
389 |
|
390 /** |
|
391 * By default Symbian 2nd phase constructor is private. |
|
392 */ |
|
393 void ConstructL(); |
|
394 |
|
395 private: // New functions |
|
396 |
|
397 /** |
|
398 * Opens the ETel store sub sub session. |
|
399 * Subclasses must overwrite this to open the store |
|
400 */ |
|
401 virtual void OpenETelStoreL() = 0; |
|
402 |
|
403 /** |
|
404 * Closes the ETel store |
|
405 */ |
|
406 virtual void CloseETelStore() = 0; |
|
407 |
|
408 private: // Implementation |
|
409 |
|
410 /// Construction after contacts are read |
|
411 void PostConstructStoreL(); |
|
412 /// Handles the store event. Creates an update command. |
|
413 void HandleStoreEventL( TInt aSimIndex ); |
|
414 /// Handles bluetooth SIM access profile dactivation |
|
415 void HandleBtSapDeactivationL(); |
|
416 /// A function called by iOpenOp |
|
417 void DoStoreOpenCallbackL( MVPbkSimStoreObserver& aObserver ); |
|
418 /// A function called by iOpenOp |
|
419 void DoStoreUnavailableCallbackL( MVPbkSimStoreObserver& aObserver ); |
|
420 /// A function called by iOpenOp |
|
421 void DoStoreErrorCallback( MVPbkSimStoreObserver& aObserver, |
|
422 TInt aError ); |
|
423 |
|
424 private: // Data |
|
425 /// The identifier of the store |
|
426 TVPbkSimStoreIdentifier iIdentifier; |
|
427 /// a phone subsession for the store |
|
428 CPhone& iPhone; |
|
429 /// Ref: a SAT refresh notifier |
|
430 CSatRefreshNotifier& iSatNotifier; |
|
431 /// Ref a bluetooth SIM access profile notifier |
|
432 CBtSapNotification& iBtSapNotifier; |
|
433 /// Ref: SIM state information |
|
434 CVPbkSimStateInformation& iSimStateInfo; |
|
435 /// Ref: an observer for the store |
|
436 RPointerArray<MVPbkSimStoreObserver> iStoreObservers; |
|
437 /// Own: a command store that handles lifetime of the commands |
|
438 CVPbkSimCommandStore* iCmdStore; |
|
439 /// Own: the array of contacts |
|
440 CContactArray* iContactArray; |
|
441 /// Own: the ETel store notication for updating store |
|
442 CETelStoreNotification* iETelNotification; |
|
443 /// The state of the store; |
|
444 TStoreState iStoreState; |
|
445 /// Own: an async call back support |
|
446 CVPbkAsyncObjectOperation<MVPbkSimStoreObserver>* iOpenOp; |
|
447 /// Own: a phone number index for fast matching |
|
448 CSimPhoneNumberIndex* iPhoneNumberIndex; |
|
449 /// Own: a contact converter |
|
450 CVPbkETelCntConverter* iCntConverter; |
|
451 /// An array of shared views. |
|
452 CSharedViewArray* iSharedViewArray; |
|
453 /// Ref: SAT refresh completion |
|
454 MSimRefreshCompletion* iSimRefreshCompletion; |
|
455 /// Ref: The system max phone number length defined by Phonebook |
|
456 TInt iSystemMaxPhoneNumberLength; |
|
457 /// The flag judge whether the BtSap is activeted. |
|
458 TBool iIsBtSapActivated; |
|
459 }; |
|
460 |
|
461 // INLINE FUNCTIONS |
|
462 inline CContactArray& CStoreBase::Contacts() |
|
463 { |
|
464 return *iContactArray; |
|
465 } |
|
466 |
|
467 inline CETelStoreNotification* CStoreBase::ETelNotification() const |
|
468 { |
|
469 return iETelNotification; |
|
470 } |
|
471 |
|
472 inline CVPbkSimStateInformation& CStoreBase::SimStateInformation() const |
|
473 { |
|
474 return iSimStateInfo; |
|
475 } |
|
476 |
|
477 inline CPhone& CStoreBase::Phone() |
|
478 { |
|
479 return iPhone; |
|
480 } |
|
481 |
|
482 inline CVPbkSimCommandStore& CStoreBase::CommandStore() |
|
483 { |
|
484 return *iCmdStore; |
|
485 } |
|
486 |
|
487 inline TStoreState CStoreBase::CurrentState() |
|
488 { |
|
489 return iStoreState; |
|
490 } |
|
491 |
|
492 } /// namespace VPbkSimStoreImpl |
|
493 |
|
494 #endif // VPBKSIMSTOREIMPL_CSTOREBASE_H |
|
495 |
|
496 // End of File |