|
1 /* |
|
2 * Copyright (c) 2008 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: Helper class to map Contacts Model fields |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPIMCONTACTFIELDINFO_H |
|
20 #define CPIMCONTACTFIELDINFO_H |
|
21 |
|
22 // INTERNAL INCLUDES |
|
23 #include "pimcommon.h" |
|
24 #include "pimcontact.h" |
|
25 |
|
26 // EXTERNAL INCLUDES |
|
27 #include <e32std.h> |
|
28 #include <cntdef.hrh> |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CContentType; |
|
32 |
|
33 /** |
|
34 * Helper clas to map fields between PIM API and Contacts |
|
35 * Model fields. |
|
36 */ |
|
37 NONSHARABLE_CLASS(CPIMContactFieldInfo) : public CBase |
|
38 { |
|
39 public: // Type definitions |
|
40 |
|
41 /** |
|
42 * Struct for mapping PIM field to a |
|
43 * Contacts Model field |
|
44 */ |
|
45 struct TPIMFieldInfo |
|
46 { |
|
47 public: |
|
48 // Constructor |
|
49 TPIMFieldInfo(TInt aContactsModelField, |
|
50 TPIMContactField aPIMField) : |
|
51 iPIMField(aPIMField), |
|
52 iSubElement(EPIMFieldInvalid), |
|
53 iContactsModelField(aContactsModelField) |
|
54 {} |
|
55 |
|
56 // Constructor with subelement |
|
57 TPIMFieldInfo(TInt aContactsModelField, |
|
58 TPIMContactField aPIMField, |
|
59 TInt aSubElement) : |
|
60 iPIMField(aPIMField), |
|
61 iSubElement(aSubElement), |
|
62 iContactsModelField(aContactsModelField) |
|
63 {} |
|
64 |
|
65 // PIM field id |
|
66 TPIMContactField iPIMField; |
|
67 // Sub field. e.g array element |
|
68 TInt iSubElement; |
|
69 // Contacts Model field id |
|
70 TInt iContactsModelField; |
|
71 }; |
|
72 |
|
73 public: |
|
74 |
|
75 /** |
|
76 * Two phase constructor |
|
77 * Returns an instance of this class |
|
78 */ |
|
79 static CPIMContactFieldInfo* NewL(); |
|
80 |
|
81 /** |
|
82 * Two phase constructor |
|
83 * Returns an instance of this class. The instance |
|
84 * is left to the cleanup stack |
|
85 */ |
|
86 static CPIMContactFieldInfo* NewLC(); |
|
87 |
|
88 /** |
|
89 * Destructor |
|
90 */ |
|
91 ~CPIMContactFieldInfo(); |
|
92 |
|
93 public: // New functions |
|
94 |
|
95 /** |
|
96 * MatchContactField |
|
97 * Matches a Contacts Model field type to |
|
98 * PIM item contact field type |
|
99 * |
|
100 * @param aContactsModelFieldType Contacts Model field type |
|
101 * @return Matched PIM contact field |
|
102 */ |
|
103 TPIMContactField MatchContactField( |
|
104 TInt aContactsModelFieldType) const; |
|
105 |
|
106 /** |
|
107 * MatchPIMField |
|
108 * Matches a PIM field to a Contacts Model field. Ownership of |
|
109 * the returned array is transferred to the caller |
|
110 * |
|
111 * @param aContactField PIM field |
|
112 * @return All matched fields with this PIM contact field. |
|
113 * In addition, one PIM field may have array elements |
|
114 * as sub elements |
|
115 */ |
|
116 CArrayFix< TInt>* MatchPIMFieldL(TPIMContactField |
|
117 aContactField) const; |
|
118 |
|
119 /** |
|
120 * MatchContactNameElement |
|
121 * Matches a Contacts Model field type to PIM contact |
|
122 * name/address element. This function should be use when |
|
123 * the actual field type is known |
|
124 * |
|
125 * @param aContactModelFieldType Contacts Model field type |
|
126 * @return Matched PIM constact name/address field array element |
|
127 */ |
|
128 TInt MatchContactArrayElement(TInt aContactsModelFieldType) const; |
|
129 |
|
130 /** |
|
131 * FieldAttributes |
|
132 * Returns the attributes of the specific Contacts Model |
|
133 * field. |
|
134 * |
|
135 * @param aContentType Content type from which to get attributes |
|
136 * @return Attributes of the passed content type |
|
137 */ |
|
138 TPIMAttribute FieldAttributes(const CContentType& aContentType) const; |
|
139 |
|
140 /** |
|
141 * GetFieldInternalAttributesL |
|
142 * Returns the internal attributes of the specific Contacts Model |
|
143 * field. |
|
144 * |
|
145 * @param aContentType Content type from which to get attributes |
|
146 * @param aArrayOfAttributes Attributes array which fields will be added |
|
147 * @return Attributes of the passed content type |
|
148 */ |
|
149 void GetFieldInternalAttributesL( |
|
150 const CContentType& aContentType, |
|
151 CArrayFix< TUid>& aArrayOfAttributes) const; |
|
152 |
|
153 /** |
|
154 * Creates a content type for a specific address element. |
|
155 * |
|
156 * @param aElement PIM Address field element |
|
157 * @param aCategory Phonebook category for the field. |
|
158 * Values can be EContactCategoryNone, |
|
159 * EContactCategoryHome, |
|
160 * EContactCategoryWork or |
|
161 * EContactCategoryOther |
|
162 * |
|
163 * @return The requested Content Type. The ownership of the object |
|
164 * is transferred to the caller. The object is left in the |
|
165 * cleanup stack. |
|
166 * |
|
167 * @par Leaving: |
|
168 * This leaves if theres an error with a system wide error code |
|
169 */ |
|
170 CContentType* AddressContentTypeL( |
|
171 TPIMContactAddrElement aElement, |
|
172 EContactFieldCategory aCategory) const; |
|
173 |
|
174 /** |
|
175 * Creates a content type for a specific name element. |
|
176 * |
|
177 * @param aElement PIM Address field element |
|
178 * |
|
179 * @return The requested Content Type. The ownership of the object |
|
180 * is transferred to the caller. |
|
181 * |
|
182 * @par Leaving: |
|
183 * This leaves if theres an error with a system wide error code |
|
184 */ |
|
185 CContentType* NameContentTypeL(TPIMContactNameElement aElement) const; |
|
186 |
|
187 /** |
|
188 * Creates a content type for a specific string field |
|
189 * |
|
190 * @param aContactField Contact field which Content Type |
|
191 * is to be created |
|
192 * @param aAttributes Attributes of this field |
|
193 * @param aCaterory Category of this field. In return, contains |
|
194 * new category if modification is needed |
|
195 * @return The requested Content Type. The ownership is transferred |
|
196 * to the caller |
|
197 */ |
|
198 CContentType* StringFieldContentTypeL( |
|
199 const TPIMContactField aContactField, |
|
200 const TPIMAttribute aAttributes, |
|
201 EContactFieldCategory& aCategory) const; |
|
202 |
|
203 private: |
|
204 |
|
205 /** |
|
206 * Default C++ constructor |
|
207 */ |
|
208 inline CPIMContactFieldInfo(); |
|
209 |
|
210 /** |
|
211 * Second phase constructor |
|
212 */ |
|
213 void ConstructL(); |
|
214 |
|
215 private: // Data |
|
216 |
|
217 // Array holding fields info |
|
218 CArrayFix< TPIMFieldInfo>* iFieldsInfo; |
|
219 |
|
220 }; |
|
221 |
|
222 #endif // CPIMCONTACTFIELDINFO_H |
|
223 // End of file |