|
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: Contact item implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPIMCONTACTITEM_H |
|
20 #define CPIMCONTACTITEM_H |
|
21 |
|
22 // INTERNAL INCLUDES |
|
23 #include "cpimitem.h" |
|
24 #include "mpimcontactitem.h" |
|
25 |
|
26 // EXTERNAL INCLUDES |
|
27 #include <cntdef.h> |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class CPIMContactValidator; |
|
31 class MPIMContactAdapterManager; |
|
32 class MPIMContactListAdapter; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * PIM item Contact specialization. |
|
38 * |
|
39 * @par Notes: |
|
40 * @li The Contact item implementation supports preferred index handling only |
|
41 * on string fields (\ref EPIMFieldString). For all other field types the |
|
42 * attribute is either leave intact (if the contact is not associated with |
|
43 * a list), or dropped silently (if the contact is associated with a list). |
|
44 */ |
|
45 NONSHARABLE_CLASS(CPIMContactItem): public CPIMItem, public MPIMContactItem |
|
46 { |
|
47 |
|
48 public: // Constructors and destructor |
|
49 |
|
50 /** |
|
51 * Two-phased constructor. |
|
52 * @param aContactValidator Contact validator. |
|
53 */ |
|
54 static CPIMContactItem* NewL( |
|
55 const CPIMContactValidator& aContactValidator); |
|
56 |
|
57 /** |
|
58 * Two-phased constructor, puts the created item into cleanup stack. |
|
59 * @param aContactValidator Contact validator. |
|
60 */ |
|
61 static CPIMContactItem* NewLC( |
|
62 const CPIMContactValidator& aContactValidator); |
|
63 |
|
64 /** |
|
65 * Destructor. |
|
66 */ |
|
67 virtual ~CPIMContactItem(); |
|
68 |
|
69 public: // New functions |
|
70 |
|
71 /** |
|
72 * Sets the associated contact adapter manager and contact list |
|
73 * adapter. |
|
74 * |
|
75 * @param aContactAdapterManager Adapter manager. Must not be NULL. |
|
76 * @param aContactListAdapter List adapter. May be NULL. |
|
77 */ |
|
78 void SetContactAdapterAssociation( |
|
79 MPIMContactAdapterManager* aContactAdapterManager, |
|
80 MPIMContactListAdapter* aContactListAdapter); |
|
81 |
|
82 /** |
|
83 * Removes the contact adapter associations. |
|
84 * Performs any housekeeping related to removing the adapter |
|
85 * associations, if necessary. |
|
86 */ |
|
87 void RemoveAdapterAssociation(); |
|
88 |
|
89 public: // Functions from CPIMItem |
|
90 |
|
91 TPIMListType ItemType() const; |
|
92 void commit(); |
|
93 void ListClosed(); |
|
94 |
|
95 /** |
|
96 * @par Notes: |
|
97 * Overridden so that first adds the string value using base class |
|
98 * AddStringL operation and then moves preferred index, if necessary. |
|
99 */ |
|
100 void AddStringL(TPIMField aField, |
|
101 TPIMAttribute aAttributes, |
|
102 HBufC* aValue); |
|
103 |
|
104 /** |
|
105 * @par Notes: |
|
106 * Overridden so that first sets the string value using base class |
|
107 * SetStringL operation and then moves preferred index, if necessary. |
|
108 */ |
|
109 void SetStringL(TPIMField aField, |
|
110 TInt aIndex, |
|
111 TPIMAttribute aAttributes, |
|
112 HBufC* aValue); |
|
113 |
|
114 TBool IsReadOnly(const TPIMField& aField); |
|
115 |
|
116 /** |
|
117 * Loads full item from the list adapter. This function |
|
118 * should be overwriten in the base class if it supports |
|
119 * partial data initialization |
|
120 */ |
|
121 void DoLoadFullItemL(); |
|
122 |
|
123 /** |
|
124 * Loads a specific field from the list adapter. This function |
|
125 * should be overwriten in the base class if it supports |
|
126 * partial data initialization |
|
127 * |
|
128 * @param aField The field which is to be loaded from |
|
129 * the associated list adapter |
|
130 */ |
|
131 void DoLoadFieldL(const TPIMField aField); |
|
132 |
|
133 public: // Functions from MPIMContactItem |
|
134 |
|
135 MPIMItemData& ItemData(); |
|
136 const MPIMItemData& ItemData() const; |
|
137 |
|
138 /** |
|
139 * @par Notes |
|
140 * @li The implementation supports preferred index only on |
|
141 * string fields (\ref EPIMFieldString). |
|
142 */ |
|
143 |
|
144 int getPreferredIndex(TPIMField aField) const; |
|
145 /** |
|
146 * Sets new contact item id for this contact item |
|
147 * |
|
148 * @param aContactItemId New id for this contact item. Old is to |
|
149 * be owerwriten |
|
150 */ |
|
151 void SetContactItemIdL(const TPIMItemID& aContactItemId); |
|
152 |
|
153 /** |
|
154 * Sets new contact item id for this contact item |
|
155 * This function was introduces for easier item id handling |
|
156 * |
|
157 * @param aContactItemId New id for this contact item. Old is to |
|
158 * be owerwriten |
|
159 */ |
|
160 void SetContactItemIdL(const TUint aContactItemId); |
|
161 |
|
162 /** |
|
163 * Returns contact item id |
|
164 * The existing PIM item id is converted to a contact |
|
165 * contact database item id, so it is easier to use it |
|
166 * |
|
167 * @return Contact item id |
|
168 */ |
|
169 TUint ContactItemIdL() const; |
|
170 |
|
171 /** |
|
172 * Sets the last modified date/time of the item |
|
173 * @param aLastModified Last modification date of this item |
|
174 */ |
|
175 void SetLastModifiedL(TPIMDate aLastModified); |
|
176 |
|
177 /** |
|
178 * Resets the item's internal state and remove all data |
|
179 * associated with this item. The item is ready for use |
|
180 * after reset |
|
181 */ |
|
182 void PrepareForLoadL(); |
|
183 |
|
184 public: // functions from pimbaseitem |
|
185 |
|
186 int getRepeatHandle() |
|
187 { |
|
188 return 0; |
|
189 } |
|
190 |
|
191 bool isItemRepeating() const |
|
192 { |
|
193 return false; |
|
194 } |
|
195 |
|
196 void setItemRepeating(jboolean /*aSetRepeating*/) {} |
|
197 |
|
198 protected: // New functions |
|
199 |
|
200 /** |
|
201 * Set preferred index for a string field. |
|
202 * Clears the preferred index attribute from all values of given field |
|
203 * and then sets the preferred index attribute for the given index. |
|
204 * |
|
205 * @par Leaving: |
|
206 * @li \c KErrArgument \a aField is invalid. |
|
207 * @li \c KErrNotFound \a aIndex is invalid. |
|
208 */ |
|
209 void SetPreferredIndexStringL( |
|
210 const TPIMField& aField, |
|
211 const TInt& aIndex, |
|
212 TPIMAttribute aAttribute); |
|
213 |
|
214 /** |
|
215 * Get preferred index (value with the "preferred" attribute set) |
|
216 * from given field. |
|
217 * |
|
218 * @return Index of the value with "preferred" attribute set; -1 if not |
|
219 * found. |
|
220 * |
|
221 * @par Leaving: |
|
222 * @li \c KErrArgument - \a aField is not supported for Contact items. |
|
223 * @li Other - internal error. |
|
224 * |
|
225 * @par Notes |
|
226 * @li The implementation supports preferred index only on |
|
227 * string fields (\ref EPIMFieldString). |
|
228 */ |
|
229 TInt DoGetPreferredIndexL(const TPIMField& aField) const; |
|
230 |
|
231 protected: // Constructors |
|
232 |
|
233 /** |
|
234 * C++ constructor. |
|
235 */ |
|
236 CPIMContactItem(const CPIMContactValidator& aContactValidator); |
|
237 |
|
238 // Data |
|
239 |
|
240 /** |
|
241 * Associated contact adapter manager. Not owned by this object. |
|
242 * May be NULL. |
|
243 */ |
|
244 MPIMContactAdapterManager* iContactAdapterManager; |
|
245 |
|
246 /** |
|
247 * Associated contact list adapter. Not owned by this object. |
|
248 * May be NULL. |
|
249 */ |
|
250 MPIMContactListAdapter* iContactListAdapter; |
|
251 |
|
252 }; |
|
253 |
|
254 #endif // CPIMCONTACTITEM_H |
|
255 // End of File |