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