|
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: A class that can convert sim contacts to etel contacts and vice |
|
15 * versa |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CVPBKETELCNTCONVERTER_H |
|
22 #define CVPBKETELCNTCONVERTER_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CPhoneBookBuffer; |
|
29 class CVPbkSimContactBuf; |
|
30 class CVPbkSimContact; |
|
31 class CVPbkSimCntField; |
|
32 class MVPbkSimCntStore; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * A class that can convert sim contacts to etel contacts and vice versa. |
|
38 * |
|
39 * @lib VPbkSimStoreImpl.lib |
|
40 */ |
|
41 class CVPbkETelCntConverter : public CBase |
|
42 { |
|
43 public: // Constructors and destructor |
|
44 |
|
45 /** |
|
46 * Two-phased constructor. |
|
47 * @return a new instance of this class |
|
48 */ |
|
49 IMPORT_C static CVPbkETelCntConverter* NewL(); |
|
50 |
|
51 /** |
|
52 * Two-phased constructor. |
|
53 * @return a new instance of this class |
|
54 */ |
|
55 IMPORT_C static CVPbkETelCntConverter* NewLC(); |
|
56 |
|
57 /** |
|
58 * Destructor. |
|
59 */ |
|
60 virtual ~CVPbkETelCntConverter(); |
|
61 |
|
62 public: // New functions |
|
63 |
|
64 /** |
|
65 * Converts ETel contacts to VPbk SIM contacts. |
|
66 * @param aResultArray an array for the converted contacts. |
|
67 * After the call the array contains a contact or contacts |
|
68 * @param aETelContactData an ETel data buffer that can contain one |
|
69 * contact or contacts |
|
70 * @param aSimStore the sim store in which the contacts belongs |
|
71 */ |
|
72 void ConvertFromETelToVPbkSimContactsL( |
|
73 RPointerArray<CVPbkSimContactBuf>& aResultArray, |
|
74 TDes8& aETelContactData, |
|
75 MVPbkSimCntStore& aSimStore ) const; |
|
76 |
|
77 /** |
|
78 * Converts one ETel contact to one VPbk SIM contact. |
|
79 * @param aETelContact one ETel contact. Sim index is not necessary. |
|
80 * @param aEmptyContact an empty contact that is filled |
|
81 * @exception KErrBadDescriptor if contact header is not found |
|
82 */ |
|
83 void ConvertFromETelToVPbkSimContactL( TDes8& aETelContact, |
|
84 CVPbkSimContact& aEmptyContact ) const; |
|
85 |
|
86 /** |
|
87 * Converts VPbk SIM fields to one ETel contact. |
|
88 * @param aFieldArray an array of VPbk SIM fields |
|
89 * @param aSimIndex the sim index of the contact that owns fields |
|
90 * @return a buffer containing an ETel contact |
|
91 */ |
|
92 HBufC8* ConvertFromVPbkSimFieldsToETelCntLC( |
|
93 const TArray<CVPbkSimCntField*>& aFieldArray, |
|
94 TInt aSimIndex ) const; |
|
95 |
|
96 /** |
|
97 * Finds the sim index from the ETel contact |
|
98 * @param aETelContact a buffer containing one ETel contact |
|
99 * @return sim index of the contact, KVPbkSimStoreFirstFreeIndex |
|
100 * if not found, KErrBadDescriptor if descriptor is invalid |
|
101 */ |
|
102 TInt SimIndex( TDes8& aETelContact ) const; |
|
103 |
|
104 /** |
|
105 * Gets the amount of supported fields in the ETel contact |
|
106 * @param aETelContact a buffer containing one ETel contact |
|
107 * @return the amount of supported fields (TVPbkSimCntFieldType) |
|
108 * or KErrBadDescriptor if aETelContact is not valid. |
|
109 */ |
|
110 TInt FieldCount( TDes8& aETelContact ) const; |
|
111 |
|
112 /** |
|
113 * Sets the field data to the given field |
|
114 * @param aETelContact a buffer containing one ETel contact |
|
115 * @param aIndex the index of the field in the contact |
|
116 * @param aField the field that will be set by the function |
|
117 */ |
|
118 void FieldAt( TDes8& aETelContact, TInt aIndex, |
|
119 CVPbkSimCntField& aField ) const; |
|
120 |
|
121 private: // Construction |
|
122 |
|
123 /** |
|
124 * C++ default constructor. |
|
125 */ |
|
126 CVPbkETelCntConverter(); |
|
127 |
|
128 /** |
|
129 * By default Symbian 2nd phase constructor is private. |
|
130 */ |
|
131 void ConstructL(); |
|
132 |
|
133 private: // New functions |
|
134 TBool MoveToNextContact() const; |
|
135 TInt StartRead() const; |
|
136 TBool GetNextField( CVPbkSimCntField& aField ) const; |
|
137 TInt NumberOfFields() const; |
|
138 TPtrC8 GetNextContactData( TDes8& aBuffer ) const; |
|
139 TInt DoFieldCount( TDes8& aETelContact, TInt& aError ) const; |
|
140 |
|
141 private: // Data |
|
142 /// Own: the ETel buffer for reading/writing an ETel contact |
|
143 CPhoneBookBuffer* iETelBuffer; |
|
144 /// The length of the new entry tag |
|
145 TInt iNewEntryTagLength; |
|
146 /// The length of the contact that has a sim index but no fields |
|
147 TInt iMinContactLength; |
|
148 }; |
|
149 |
|
150 #endif // CVPBKETELCNTCONVERTER_H |
|
151 |
|
152 // End of File |