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: Implementation of contact data container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "cvimpststoragecontact.h" |
|
22 #include "tvimpstenums.h" |
|
23 #include "uiservicetabtracer.h" |
|
24 #include "cvimpststoragedefs.h" |
|
25 |
|
26 #include <MVPbkStoreContact.h> |
|
27 #include <MVPbkContactLink.h> |
|
28 #include <e32base.h> |
|
29 #include "mvimpststoragevpbkcontactstore.h" |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CVIMPSTStorageContact::CVIMPSTStorageContact |
|
35 // C++ default constructor can NOT contain any code, that |
|
36 // might leave. |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CVIMPSTStorageContact::CVIMPSTStorageContact() |
|
40 { |
|
41 iPresenceStatus = TVIMPSTEnums::EOffline; |
|
42 iAvatarIndex = 0; |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CVIMPSTStorageContact::ConstructL |
|
47 // Symbian 2nd phase constructor can leave. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 void CVIMPSTStorageContact::ConstructL(const TDesC& aUserId, |
|
51 const TDesC& aDisplayName, |
|
52 const MVPbkContactLink& aContactLink, |
|
53 const TDesC8& aAvatarContent ) |
|
54 { |
|
55 TRACER_AUTO; |
|
56 iUserId = aUserId.AllocL(); |
|
57 iDisplayName = aDisplayName.AllocL(); |
|
58 MVPbkContactLink* link = aContactLink.CloneLC(); |
|
59 iContactLink = link; |
|
60 CleanupStack::Pop(); // link |
|
61 iAvatarContent = aAvatarContent.AllocL(); |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CVIMPSTStorageContact::ConstructL |
|
66 // Symbian 2nd phase constructor can leave. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void CVIMPSTStorageContact::ConstructL(const TDesC& aUserId, |
|
70 const TDesC& aDisplayName ) |
|
71 { |
|
72 TRACER_AUTO; |
|
73 iUserId = aUserId.AllocL(); |
|
74 iDisplayName = aDisplayName.AllocL(); |
|
75 } |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CVIMPSTStorageContact::NewL |
|
78 // Two-phased constructor. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 CVIMPSTStorageContact* CVIMPSTStorageContact::NewL(const TDesC& aUserId, |
|
82 const TDesC& aDisplayName, |
|
83 const MVPbkContactLink& aContactLink, |
|
84 const TDesC8& aAvatarContent) |
|
85 { |
|
86 TRACER_AUTO; |
|
87 CVIMPSTStorageContact* self = CVIMPSTStorageContact::NewLC( aUserId,aDisplayName,aContactLink,aAvatarContent ); |
|
88 CleanupStack::Pop( self ); |
|
89 return self; |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CVIMPSTStorageContact::NewL |
|
94 // Two-phased constructor. |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 CVIMPSTStorageContact* CVIMPSTStorageContact::NewL(const TDesC& aUserId, |
|
98 const TDesC& aDisplayName ) |
|
99 { |
|
100 TRACER_AUTO; |
|
101 CVIMPSTStorageContact* self = new (ELeave) CVIMPSTStorageContact(); |
|
102 CleanupStack::PushL( self ); |
|
103 self->ConstructL( aUserId,aDisplayName ); |
|
104 CleanupStack::Pop( self ); |
|
105 return self; |
|
106 } |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CVIMPSTStorageContact::NewLC |
|
109 // Two-phased constructor. |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 CVIMPSTStorageContact* CVIMPSTStorageContact::NewLC(const TDesC& aUserId, |
|
113 const TDesC& aDisplayName, |
|
114 const MVPbkContactLink& aContactLink, |
|
115 const TDesC8& aAvatarContent) |
|
116 { |
|
117 TRACER_AUTO; |
|
118 CVIMPSTStorageContact* self = new( ELeave ) CVIMPSTStorageContact(); |
|
119 CleanupStack::PushL( self ); |
|
120 self->ConstructL( aUserId,aDisplayName,aContactLink ,aAvatarContent); |
|
121 return self; |
|
122 } |
|
123 |
|
124 // Destructor |
|
125 CVIMPSTStorageContact::~CVIMPSTStorageContact() |
|
126 { |
|
127 |
|
128 if(iContactLink) |
|
129 { |
|
130 |
|
131 delete iContactLink; |
|
132 iContactLink = NULL; |
|
133 } |
|
134 |
|
135 delete iUserId; |
|
136 delete iDisplayName; |
|
137 delete iStatusText; |
|
138 delete iAvatarContent; |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CVIMPSTStorageContact::UserId |
|
143 // From MVIMPSTStorageContact |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 const TDesC& CVIMPSTStorageContact::UserId() const |
|
147 { |
|
148 TRACER_AUTO; |
|
149 if( iUserId ) |
|
150 { |
|
151 return *iUserId; |
|
152 } |
|
153 return KNullDesC; |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CVIMPSTStorageContact::UserId |
|
158 // From MVIMPSTStorageContact |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 const TDesC& CVIMPSTStorageContact::Name() const |
|
162 { |
|
163 TRACER_AUTO; |
|
164 if( iDisplayName ) |
|
165 { |
|
166 return *iDisplayName; |
|
167 } |
|
168 return KNullDesC; |
|
169 } |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CVIMPSTStorageContact::OnlineStatus |
|
172 // From MVIMPSTStorageContact |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 TVIMPSTEnums::TOnlineStatus CVIMPSTStorageContact::OnlineStatus() const |
|
176 { |
|
177 return iPresenceStatus; |
|
178 } |
|
179 |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CVIMPSTStorageContact::SetOnlineStatus |
|
183 // From MVIMPSTStorageContact |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 void CVIMPSTStorageContact::SetOnlineStatus( |
|
187 TVIMPSTEnums::TOnlineStatus aOnlineStatus ) |
|
188 { |
|
189 iPresenceStatus = aOnlineStatus; |
|
190 } |
|
191 |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CVIMPSTStorageContact::StatusText |
|
195 // From MVIMPSTStorageContact |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 const TDesC& CVIMPSTStorageContact::StatusText() const |
|
199 { |
|
200 TRACER_AUTO; |
|
201 if( iStatusText ) |
|
202 { |
|
203 return *iStatusText; |
|
204 } |
|
205 return KNullDesC; |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CVIMPSTStorageContact::SetStatusTextL |
|
210 // From MVIMPSTStorageContact |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 void CVIMPSTStorageContact::SetStatusTextL( const TDesC& aStatusText ) |
|
214 { |
|
215 if( iStatusText ) |
|
216 { |
|
217 delete iStatusText; |
|
218 iStatusText = NULL; |
|
219 } |
|
220 iStatusText= aStatusText.AllocL(); |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CVIMPSTStorageContact::SetAvatarContentL |
|
225 // From MVIMPSTStorageContact |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 void CVIMPSTStorageContact::SetAvatarContentL( const TDesC8& aAvatarContent ,MVIMPSTStorageVPbkContactStore& aVPPkStoreHandler ) |
|
229 { |
|
230 TRACER_AUTO; |
|
231 if( iAvatarContent ) |
|
232 { |
|
233 if( iAvatarContent->Compare( aAvatarContent ) == 0 ) |
|
234 { |
|
235 // no need to set |
|
236 return; |
|
237 } |
|
238 delete iAvatarContent; |
|
239 iAvatarContent = NULL; |
|
240 } |
|
241 iAvatarContent = aAvatarContent.AllocL(); |
|
242 if( iContactLink ) |
|
243 { |
|
244 aVPPkStoreHandler.UpdateAvatarFieldDataL(*iContactLink, *iAvatarContent); |
|
245 } |
|
246 } |
|
247 |
|
248 |
|
249 // ----------------------------------------------------------------------------- |
|
250 // CVIMPSTStorageContact::SetUserIdL |
|
251 // From MVIMPSTStorageExtendedStorageContact |
|
252 // ----------------------------------------------------------------------------- |
|
253 // |
|
254 void CVIMPSTStorageContact::SetUserIdL( const TDesC& aUserId ) |
|
255 { |
|
256 if( iUserId ) |
|
257 { |
|
258 delete iUserId; |
|
259 iUserId = NULL; |
|
260 } |
|
261 iUserId = aUserId.AllocL(); |
|
262 } |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // CVIMPSTStorageContact::SetNameL |
|
266 // From MVIMPSTStorageExtendedStorageContact |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 void CVIMPSTStorageContact::SetNameL( const TDesC& aName ) |
|
270 { |
|
271 TRACER_AUTO; |
|
272 if( iDisplayName ) |
|
273 { |
|
274 delete iDisplayName; |
|
275 iDisplayName = NULL; |
|
276 } |
|
277 iDisplayName= aName.AllocL(); |
|
278 } |
|
279 // --------------------------------------------------------------------------- |
|
280 // CVIMPSTStorageContact::ContactLink() |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 MVPbkContactLink* CVIMPSTStorageContact::ContactLink() const |
|
284 { |
|
285 return iContactLink; |
|
286 } |
|
287 |
|
288 // --------------------------------------------------------------------------- |
|
289 // CVIMPSTStorageContact::AvatarContent |
|
290 // --------------------------------------------------------------------------- |
|
291 // |
|
292 const TDesC8& CVIMPSTStorageContact::AvatarContent() const |
|
293 { |
|
294 if( iAvatarContent ) |
|
295 { |
|
296 return *iAvatarContent; |
|
297 } |
|
298 return KNullDesC8(); |
|
299 } |
|
300 // --------------------------------------------------------------------------- |
|
301 // CVIMPSTStorageContact::SetAvatarIndex() |
|
302 // --------------------------------------------------------------------------- |
|
303 // |
|
304 void CVIMPSTStorageContact::SetAvatarIndex(TInt aIndex ) |
|
305 { |
|
306 iAvatarIndex = aIndex; |
|
307 } |
|
308 |
|
309 // --------------------------------------------------------------------------- |
|
310 // CVIMPSTStorageContact::AvatarIndex |
|
311 // --------------------------------------------------------------------------- |
|
312 // |
|
313 TInt CVIMPSTStorageContact::AvatarIndex() const |
|
314 { |
|
315 return iAvatarIndex; |
|
316 } |
|
317 |
|
318 // End of File |
|