|
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: An editable sim contact |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CVPBKSIMCONTACT_H |
|
21 #define CVPBKSIMCONTACT_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "CVPbkSimContactBase.h" |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class MVPbkSimCntStore; |
|
28 class MVPbkSimContactObserver; |
|
29 class MVPbkSimStoreOperation; |
|
30 |
|
31 // CLASS DECLARATION |
|
32 |
|
33 /** |
|
34 * The sim contact |
|
35 * |
|
36 * @lib VPbkSimStoreImpl.lib |
|
37 */ |
|
38 class CVPbkSimContact : public CVPbkSimContactBase |
|
39 { |
|
40 public: // Constructors and destructor |
|
41 |
|
42 /** |
|
43 * Two-phased constructor. |
|
44 * @param aETelContact an ETel contact |
|
45 * @param aSimStore the sim store in which this contact belongs |
|
46 * @return a new instance of this class |
|
47 * @exception KErrBadDescriptor if contact couldn't be initialized |
|
48 */ |
|
49 IMPORT_C static CVPbkSimContact* NewL( const TDesC8& aETelContact, |
|
50 MVPbkSimCntStore& aSimStore ); |
|
51 |
|
52 /** |
|
53 * Two-phased constructor. Creates a new empty sim contact. |
|
54 * @param aSimStore the sim store in which this contact belongs |
|
55 * @return a new instance of this class |
|
56 */ |
|
57 IMPORT_C static CVPbkSimContact* NewL( MVPbkSimCntStore& aSimStore ); |
|
58 |
|
59 /** |
|
60 * Two-phased constructor. |
|
61 * @param aETelContact an ETel contact |
|
62 * @param aSimStore the sim store in which this contact belongs |
|
63 * @return a new instance of this class |
|
64 * @exception KErrBadDescriptor if contact couldn't be initialized |
|
65 */ |
|
66 IMPORT_C static CVPbkSimContact* NewLC( const TDesC8& aETelContact, |
|
67 MVPbkSimCntStore& aSimStore ); |
|
68 |
|
69 /** |
|
70 * Two-phased constructor. Creates a new empty sim contact. |
|
71 * @param aSimStore the sim store in which this contact belongs |
|
72 * @return a new instance of this class |
|
73 */ |
|
74 IMPORT_C static CVPbkSimContact* NewLC( MVPbkSimCntStore& aSimStore ); |
|
75 |
|
76 /** |
|
77 * Destructor. |
|
78 */ |
|
79 virtual ~CVPbkSimContact(); |
|
80 |
|
81 public: // New functions |
|
82 |
|
83 /** |
|
84 * Creates a new field. |
|
85 * @param aType the type of the field |
|
86 * @return a new field instance |
|
87 */ |
|
88 IMPORT_C CVPbkSimCntField* CreateFieldLC( |
|
89 TVPbkSimCntFieldType aType ) const; |
|
90 |
|
91 /** |
|
92 * Deletes a field in the specified position |
|
93 * @param aIndex the index of the field to be deleted |
|
94 */ |
|
95 IMPORT_C void DeleteField( TInt aIndex ); |
|
96 |
|
97 /** |
|
98 * Adds a new field to the contact. |
|
99 * @param aField the new field. Ownership is taken. NULL field |
|
100 * is ignored. |
|
101 */ |
|
102 IMPORT_C void AddFieldL( CVPbkSimCntField* aField ); |
|
103 |
|
104 /** |
|
105 * Deletes all fields from the contact |
|
106 */ |
|
107 IMPORT_C void DeleteAllFields(); |
|
108 |
|
109 /** |
|
110 * Saves this contact |
|
111 * @param aObserver the observer to notify after async save |
|
112 * @precond FieldCount() > 0 |
|
113 * VPbkSimStoreImpl::Panic(VPbkSimStoreImpl::EZeroFieldCount) |
|
114 * is raised if the precondition does not hold. |
|
115 * @return an asynchrnous operation handle that can be used to cancel request. |
|
116 */ |
|
117 IMPORT_C MVPbkSimStoreOperation* SaveL( |
|
118 MVPbkSimContactObserver& aObserver ); |
|
119 |
|
120 /** |
|
121 * Returns a field in given index. |
|
122 * @param aIndex the index of the field |
|
123 * @return a field in given index. |
|
124 */ |
|
125 inline CVPbkSimCntField& FieldAt( TInt aIndex ); |
|
126 |
|
127 /** |
|
128 * Returns the field array |
|
129 * @return the field array |
|
130 */ |
|
131 inline RPointerArray<CVPbkSimCntField>& FieldArray(); |
|
132 |
|
133 /** |
|
134 * Set the sim index of the contact |
|
135 * @param aSimIndex the sim index of the contact |
|
136 */ |
|
137 void SetSimIndex( TInt aSimIndex ); |
|
138 |
|
139 public: // Functions from base classes |
|
140 |
|
141 /** |
|
142 * From MVPbkSimContact |
|
143 */ |
|
144 const CVPbkSimCntField& ConstFieldAt( TInt aIndex ) const; |
|
145 |
|
146 /** |
|
147 * From MVPbkSimContact |
|
148 */ |
|
149 TInt FieldCount() const; |
|
150 |
|
151 /** |
|
152 * From MVPbkSimContact |
|
153 */ |
|
154 TInt SimIndex() const; |
|
155 |
|
156 /** |
|
157 * From MVPbkSimContact |
|
158 */ |
|
159 const TDesC8& ETelContactL() const; |
|
160 |
|
161 /** |
|
162 * From MVPbkSimContact |
|
163 */ |
|
164 void SetL( const TDesC8& aETelContact ); |
|
165 |
|
166 private: |
|
167 |
|
168 /** |
|
169 * C++ constructor. |
|
170 */ |
|
171 CVPbkSimContact( MVPbkSimCntStore& aSimStore ); |
|
172 |
|
173 /** |
|
174 * By default Symbian 2nd phase constructor is private. |
|
175 */ |
|
176 void ConstructL( const TDesC8* aETelContact ); |
|
177 |
|
178 private: // New functions |
|
179 /// Creates ETel contact from native fields |
|
180 void CreateETelContactL() const; |
|
181 |
|
182 private: // Data |
|
183 /// The array for the fields |
|
184 RPointerArray<CVPbkSimCntField> iFieldArray; |
|
185 /// Own: a buffer for ETel format, mutable because ETelContactL() |
|
186 /// is const. Calling ETelContactL() doesn't changes the contact data |
|
187 /// but makes a conversion to ETel format. |
|
188 mutable HBufC8* iData; |
|
189 /// The sim index of the contact |
|
190 TInt iSimIndex; |
|
191 }; |
|
192 |
|
193 |
|
194 // INLINE FUNCTIONS |
|
195 inline CVPbkSimCntField& CVPbkSimContact::FieldAt( TInt aIndex ) |
|
196 { |
|
197 return *iFieldArray[aIndex]; |
|
198 } |
|
199 |
|
200 inline RPointerArray<CVPbkSimCntField>& CVPbkSimContact::FieldArray() |
|
201 { |
|
202 return iFieldArray; |
|
203 } |
|
204 |
|
205 #endif // CVPBKSIMCONTACT_H |
|
206 |
|
207 // End of File |