|
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 details view plugin |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cvimpstdetailsviewplugin.h" |
|
20 |
|
21 #include "cvimpstdetailsviewcontainer.h" |
|
22 #include "cvimpstdetailsviewlistboxmodel.h" |
|
23 #include "cvimpstdetailsviewmenuhandler.h" |
|
24 #include "vimpstdetailsviewpluginuids.hrh" |
|
25 #include "cvimpstdetailsviewbrandhandler.h" |
|
26 #include "cvimpstdetailscontacthandler.h" |
|
27 |
|
28 #include "vimpstdetailsview.hrh" |
|
29 #include <vimpstui.mbg> |
|
30 #include <conversations.mbg> |
|
31 #include <vimpstdetailsviewpluginrsc.rsg> |
|
32 #include "cvimpstdetailspresencehandler.h" |
|
33 |
|
34 #include <imconnectionproviderconsts.h> |
|
35 |
|
36 #include <bautils.h> |
|
37 #include <AknIconUtils.h> |
|
38 #include <AiwServiceHandler.h> |
|
39 #include <AknsUtils.h> |
|
40 #include <e32property.h> |
|
41 #include <StringLoader.h> |
|
42 // cca |
|
43 #include <ccappviewpluginakncontainer.h> |
|
44 #include <mccapppluginparameter.h> |
|
45 #include <mccaparameter.h> |
|
46 |
|
47 // settings |
|
48 #include <spsettings.h> |
|
49 #include <spentry.h> |
|
50 #include <spproperty.h> |
|
51 |
|
52 // Virtual Phonebook |
|
53 #include <CVPbkContactLinkArray.h> |
|
54 #include "vimpstdebugtrace.h" |
|
55 // meco service uid |
|
56 #define KMECOIMPLEMENTATIONUID 0x20012423 |
|
57 _LIT(KVIMPSTDetailsViewDllResFileName, "\\resource\\vimpstdetailsviewpluginrsc.rsc"); |
|
58 _LIT8( KEMbmConversationsQgnDefaultImage, "default_brand_image"); |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // CVIMPSTDetailsViewPlugin::NewL |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 CVIMPSTDetailsViewPlugin* CVIMPSTDetailsViewPlugin::NewL(TInt aServiceId) |
|
65 { |
|
66 CVIMPSTDetailsViewPlugin* self = new(ELeave) CVIMPSTDetailsViewPlugin(aServiceId); |
|
67 CleanupStack::PushL(self); |
|
68 self->ConstructL(); |
|
69 CleanupStack::Pop(self); |
|
70 return self; |
|
71 } |
|
72 // --------------------------------------------------------------------------- |
|
73 // CVIMPSTDetailsViewPlugin::~CVIMPSTDetailsViewPlugin |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 CVIMPSTDetailsViewPlugin::~CVIMPSTDetailsViewPlugin() |
|
77 { |
|
78 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::~CVIMPSTDetailsViewPlugin start") ); |
|
79 delete iMenuHandler; |
|
80 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::~CVIMPSTDetailsViewPlugin iMenuHandler deleted") ); |
|
81 delete iBrandHandler; |
|
82 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::~CVIMPSTDetailsViewPlugin iBrandHandler deleted") ); |
|
83 delete iPresenceHandler; |
|
84 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::~CVIMPSTDetailsViewPlugin iPresenceHandler deleted") ); |
|
85 delete iContactHandler; |
|
86 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::~CVIMPSTDetailsViewPlugin end") ); |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CVIMPSTDetailsViewPlugin::CVIMPSTDetailsViewPlugin() |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 CVIMPSTDetailsViewPlugin::CVIMPSTDetailsViewPlugin(TInt aServiceId) : iFocusedListIndex(0), |
|
94 iServiceId (aServiceId) |
|
95 { |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CVIMPSTDetailsViewPlugin::ConstructL |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 void CVIMPSTDetailsViewPlugin::ConstructL() |
|
103 { |
|
104 iBrandHandler = CVIMPSTDetailsViewBrandHandler::NewL( iServiceId ); |
|
105 } |
|
106 // --------------------------------------------------------------------------- |
|
107 // CVIMPSTDetailsViewPlugin::PreparePluginViewL |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 void CVIMPSTDetailsViewPlugin::PreparePluginViewL( |
|
111 MCCAppPluginParameter& aPluginParameter) |
|
112 { |
|
113 // check parameter version |
|
114 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::PreparePluginViewL start") ); |
|
115 if (aPluginParameter.Version() != 1) |
|
116 { |
|
117 User::Leave(KErrNotSupported); |
|
118 } |
|
119 |
|
120 if (aPluginParameter.CCAppLaunchParameter().ContactDataFlag() == |
|
121 MCCAParameter::EContactLink) |
|
122 { |
|
123 iLaunchParameter = &aPluginParameter.CCAppLaunchParameter(); |
|
124 } |
|
125 |
|
126 PrepareViewResourcesL(); |
|
127 |
|
128 HBufC* serviceName = HBufC::NewLC( KVIMPST_MAX_LENGTH ); |
|
129 TPtr serviceNamePtr = serviceName->Des() ; |
|
130 iBrandHandler->GetServiceNameL( serviceNamePtr ); |
|
131 //initialize the presence cache. |
|
132 iPresenceHandler = CVIMPSTDetailsPresenceHandler::NewL( serviceNamePtr,*this, |
|
133 iBrandHandler->ServiceSupportedL() ); |
|
134 |
|
135 iContactHandler = CVIMPSTDetailsContactHandler::NewL( *iLaunchParameter , |
|
136 *this, |
|
137 iBrandHandler->ServiceStoreUriL(), |
|
138 serviceNamePtr, |
|
139 iServiceId); |
|
140 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::PreparePluginViewL iContactHandler created") ); |
|
141 CleanupStack::PopAndDestroy(); // serviceName |
|
142 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::PreparePluginViewL end") ); |
|
143 } |
|
144 // --------------------------------------------------------------------------- |
|
145 // CVIMPSTDetailsViewPlugin::ImplementationUid |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 TUid CVIMPSTDetailsViewPlugin::ImplementationUid() |
|
149 { |
|
150 return TUid::Uid(KVIMPSTDetailsViewPluginImplmentationUid ); |
|
151 } |
|
152 // --------------------------------------------------------------------------- |
|
153 // CVIMPSTDetailsViewPlugin::ProvideBitmapLC |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 void CVIMPSTDetailsViewPlugin::ProvideBitmapLC( |
|
157 TCCAppIconType aIconType, CFbsBitmap*& aBitmap, CFbsBitmap*& aBitmapMask) |
|
158 { |
|
159 if (ECCAppTabIcon == aIconType) |
|
160 { |
|
161 CFbsBitmap* bmp = NULL; |
|
162 CFbsBitmap* bmpMask = NULL; |
|
163 |
|
164 // Create icon array |
|
165 iBrandHandler->LoadBitMapLC( |
|
166 bmp, |
|
167 bmpMask, |
|
168 EMbmConversationsQgn_prop_im_imsg, |
|
169 EMbmConversationsQgn_prop_im_imsg_mask |
|
170 ); |
|
171 |
|
172 aBitmap = bmp; |
|
173 aBitmapMask = bmpMask; |
|
174 } |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // CVIMPSTDetailsViewPlugin::ProvideBitmapL |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 void CVIMPSTDetailsViewPlugin::ProvideBitmapL( |
|
182 TCCAppIconType aIconType, CAknIcon& aIcon) |
|
183 |
|
184 { |
|
185 if (ECCAppTabIcon == aIconType) |
|
186 { |
|
187 CFbsBitmap* bmp = NULL; |
|
188 CFbsBitmap* bmpMask = NULL; |
|
189 CGulIcon* tabIcon = iBrandHandler->LoadBrandBitmapL(KEMbmConversationsQgnDefaultImage); |
|
190 if(tabIcon) |
|
191 { |
|
192 bmp = tabIcon->Bitmap(); |
|
193 bmpMask = tabIcon->Mask(); |
|
194 aIcon.SetBitmap(bmp); // ownership transfer to aIcon |
|
195 aIcon.SetMask(bmpMask); // ownership transfer to aIcon |
|
196 // this is remove the memory leak |
|
197 tabIcon->SetBitmapsOwnedExternally( ETrue ); |
|
198 delete tabIcon ; |
|
199 } |
|
200 } |
|
201 } |
|
202 |
|
203 // --------------------------------------------------------------------------- |
|
204 // CVIMPSTDetailsViewPlugin::NewContainerL |
|
205 // --------------------------------------------------------------------------- |
|
206 // |
|
207 void CVIMPSTDetailsViewPlugin::NewContainerL() |
|
208 { |
|
209 if( iBrandHandler && iLaunchParameter ) |
|
210 { |
|
211 iContainer = new (ELeave) CVIMPSTDetailsViewContainer( Id(), |
|
212 *iBrandHandler, |
|
213 *iPresenceHandler, |
|
214 iFocusedListIndex ); |
|
215 } |
|
216 |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // CVIMPSTDetailsViewPlugin::DynInitMenuPaneL |
|
221 // --------------------------------------------------------------------------- |
|
222 // |
|
223 void CVIMPSTDetailsViewPlugin::DynInitMenuPaneL(TInt aResourceId, |
|
224 CEikMenuPane* aMenuPane) |
|
225 { |
|
226 if (!iMenuHandler) |
|
227 { |
|
228 iMenuHandler = CVIMPSTDetailsViewMenuHandler::NewL(*this, |
|
229 iContactHandler->StoreType() ); |
|
230 } |
|
231 iMenuHandler->DynInitMenuPaneL(aResourceId, aMenuPane); |
|
232 } |
|
233 |
|
234 // --------------------------------------------------------------------------- |
|
235 // CVIMPSTDetailsViewPlugin::HandleCommandL |
|
236 // --------------------------------------------------------------------------- |
|
237 // |
|
238 void CVIMPSTDetailsViewPlugin::HandleCommandL(TInt aCommand) |
|
239 { |
|
240 // CCApp handles the "Exit"- and "Back"-commands, |
|
241 // rest to menuhandler |
|
242 CCCAppViewPluginAknView::HandleCommandL(aCommand); |
|
243 |
|
244 iMenuHandler->HandleCommandL(aCommand); |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // CVIMPSTDetailsViewPlugin::Id |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 TUid CVIMPSTDetailsViewPlugin::Id() const |
|
252 { |
|
253 return TUid::Uid(KVIMPSTDetailsViewPluginImplmentationUid + iServiceId); |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // CVIMPSTDetailsViewPlugin::PrepareViewResourcesL |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 void CVIMPSTDetailsViewPlugin::PrepareViewResourcesL() |
|
261 { |
|
262 // Ignore codescanner warning generated here : " Leaving function called before BaseConstructL " |
|
263 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::PrepareViewResourcesL start") ); |
|
264 TFileName fileName(KVIMPSTDetailsViewDllResFileName); |
|
265 BaflUtils::NearestLanguageFile(iCoeEnv->FsSession(), fileName); |
|
266 iResourceLoader.OpenL(fileName); |
|
267 BaseConstructL(R_VIMPSTDETAILSVIEW_MAINVIEW); |
|
268 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::PrepareViewResourcesL end") ); |
|
269 } |
|
270 |
|
271 // --------------------------------------------------------------------------- |
|
272 // CVIMPSTDetailsViewPlugin::DoActivateL |
|
273 // --------------------------------------------------------------------------- |
|
274 // |
|
275 void CVIMPSTDetailsViewPlugin::DoActivateL( |
|
276 const TVwsViewId& aPrevViewId, |
|
277 TUid aCustomMessageId, |
|
278 const TDesC8& aCustomMessage) |
|
279 { |
|
280 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::DoActivateL start") ); |
|
281 CCCAppViewPluginAknView::DoActivateL(aPrevViewId, aCustomMessageId, |
|
282 aCustomMessage); |
|
283 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::DoActivateL calling GetContactData") ); |
|
284 GetContactDataL(); |
|
285 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::DoActivateL end") ); |
|
286 } |
|
287 |
|
288 // --------------------------------------------------------------------------- |
|
289 // CVIMPSTDetailsViewPlugin::DoDeactivate |
|
290 // --------------------------------------------------------------------------- |
|
291 // |
|
292 void CVIMPSTDetailsViewPlugin::DoDeactivate() |
|
293 { |
|
294 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::DoDeactivate satrt") ); |
|
295 if( iContactHandler ) |
|
296 { |
|
297 iContactHandler->CancelOngoingRequest(); |
|
298 } |
|
299 |
|
300 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::DoDeactivate ongoing request canceled") ); |
|
301 if (iContainer) |
|
302 { |
|
303 iFocusedListIndex = static_cast<CVIMPSTDetailsViewContainer*> |
|
304 (iContainer)->ListBoxModel().FocusedFieldIndex(); |
|
305 } |
|
306 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::DoDeactivate calling base class Deactivate") ); |
|
307 CCCAppViewPluginAknView::DoDeactivate(); |
|
308 // not woned by this class |
|
309 iContainer = NULL; |
|
310 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::DoDeactivate end") ); |
|
311 } |
|
312 |
|
313 // -------------------------------------------------------------------------- |
|
314 // CVIMPSTDetailsViewPlugin::GetContactDataL |
|
315 // -------------------------------------------------------------------------- |
|
316 // |
|
317 void CVIMPSTDetailsViewPlugin::GetContactDataL() |
|
318 { |
|
319 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::GetContactDataL start") ); |
|
320 if (iLaunchParameter && iContactHandler ) |
|
321 { |
|
322 // todo: pass launchparameter to listbox model? |
|
323 HBufC& contactData = iLaunchParameter->ContactDataL(); |
|
324 |
|
325 HBufC8* buf = HBufC8::NewLC(contactData.Length()); |
|
326 buf->Des().Copy(contactData); |
|
327 TPtrC8 bufDes(buf->Des()); |
|
328 |
|
329 CVPbkContactLinkArray* links = CVPbkContactLinkArray::NewLC( bufDes, iContactHandler->ContactStoresL() ); |
|
330 CleanupStack::Pop(links); |
|
331 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::GetContactDataL links created") ); |
|
332 CleanupStack::PopAndDestroy(buf); |
|
333 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::GetContactDataL buffer destroyed") ); |
|
334 TUid launchUid = iLaunchParameter->LaunchedViewUid(); |
|
335 if( launchUid.iUid != (KVIMPSTDetailsViewPluginImplmentationUid+iServiceId) && iContactHandler->StoreType() == EStoreServer ) |
|
336 { |
|
337 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::GetContactDataL service store set link called from pbk") ); |
|
338 // launch from other than service tab |
|
339 // ETrue, read xsp id from pbk store and search in service store and show |
|
340 // incase of xsp store , need to find the details from xsp store |
|
341 iContactHandler->SetLinks( links , ETrue ); |
|
342 } |
|
343 else |
|
344 { |
|
345 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::GetContactDataL set linkcalled from service tab/CV") ); |
|
346 iContactHandler->SetLinks( links , EFalse ); |
|
347 //make sure this is set to null after view is changed |
|
348 // cannot be set it to null in dodeactivate call. as ilaunchparameter is not |
|
349 //owned by us. might get destryoed by cca |
|
350 iLaunchParameter->SetLaunchedViewUid(TUid::Null()); |
|
351 } |
|
352 } |
|
353 TRACED( T_LIT("CVIMPSTDetailsViewPlugin::GetContactDataL end") ); |
|
354 } |
|
355 // --------------------------------------------------------------------------- |
|
356 // CVIMPSTDetailsViewPlugin::SetTitleL |
|
357 // --------------------------------------------------------------------------- |
|
358 // |
|
359 void CVIMPSTDetailsViewPlugin::SetTitleL() |
|
360 { |
|
361 HBufC* title = NULL; |
|
362 |
|
363 if( iContainer && iContactHandler ) |
|
364 { |
|
365 title = static_cast<CVIMPSTDetailsViewContainer*> |
|
366 (iContainer)->GetTitleTextLC( iContactHandler->StoreType() ); |
|
367 } |
|
368 if( !title ) |
|
369 { |
|
370 if(iContactHandler) |
|
371 { |
|
372 title = iContactHandler->GetDisplayNameLC(); |
|
373 } |
|
374 } |
|
375 // Forward the SetTitleL-call to base-class |
|
376 if( title ) |
|
377 { |
|
378 CCCAppViewPluginAknView::SetTitleL( *title ); |
|
379 CleanupStack::PopAndDestroy(); // title |
|
380 } |
|
381 } |
|
382 |
|
383 // -------------------------------------------------------------------------- |
|
384 // CVIMPSTDetailsViewPlugin::HandlePresenceChangedL |
|
385 // -------------------------------------------------------------------------- |
|
386 // |
|
387 void CVIMPSTDetailsViewPlugin::HandlePresenceChangedL() |
|
388 { |
|
389 if( iContainer ) |
|
390 { |
|
391 static_cast<CVIMPSTDetailsViewContainer*> |
|
392 (iContainer)->PresenceChangedL(); |
|
393 } |
|
394 |
|
395 } |
|
396 // -------------------------------------------------------------------------- |
|
397 // CVIMPSTDetailsViewPlugin::HandleContactReadyL |
|
398 // -------------------------------------------------------------------------- |
|
399 // |
|
400 void CVIMPSTDetailsViewPlugin::HandleContactReadyL( MVPbkStoreContact& aContact ) |
|
401 { |
|
402 if( iContainer ) |
|
403 { |
|
404 // read the service name for servic eid - iServiceId |
|
405 // pass to CreatePresentation |
|
406 HBufC* serviceName = HBufC::NewLC( KVIMPST_MAX_LENGTH ); |
|
407 TPtr serviceNamePtr = serviceName->Des() ; |
|
408 iBrandHandler->GetServiceNameL( serviceNamePtr ); |
|
409 |
|
410 static_cast<CVIMPSTDetailsViewContainer*> |
|
411 (iContainer)->CreatePresentationL( aContact ,*serviceName, iContactHandler->StoreType() ); |
|
412 // delete service name |
|
413 CleanupStack::PopAndDestroy();//serviceName |
|
414 } |
|
415 SetTitleL(); // call only after presentation is created |
|
416 } |
|
417 |
|
418 // -------------------------------------------------------------------------- |
|
419 // CVIMPSTDetailsViewPlugin::HandleContactUnavailableL |
|
420 // -------------------------------------------------------------------------- |
|
421 // |
|
422 void CVIMPSTDetailsViewPlugin::HandleContactUnavailableL() |
|
423 { |
|
424 if( iContainer ) |
|
425 { |
|
426 static_cast<CVIMPSTDetailsViewContainer*> |
|
427 (iContainer)->CreateEmptyPresentationL(); |
|
428 } |
|
429 SetTitleL(); // call only after presentation is created |
|
430 } |
|
431 |
|
432 // -------------------------------------------------------------------------- |
|
433 // CVIMPSTDetailsViewPlugin::GetContactHandler |
|
434 // -------------------------------------------------------------------------- |
|
435 // |
|
436 CVIMPSTDetailsContactHandler* CVIMPSTDetailsViewPlugin::GetContactHandler() |
|
437 { |
|
438 return iContactHandler; |
|
439 } |
|
440 // End of File |
|
441 |
|
442 |