|
1 /* |
|
2 * Copyright (c) 2009-2009 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 MyCard plugin |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ccappmycardplugin.h" |
|
20 #include "ccappmycardcontainer.h" |
|
21 #include "ccappmycardcommon.h" |
|
22 #include "ccappmycardpluginuids.hrh" |
|
23 #include "ccappmycard.h" |
|
24 #include "ccappmycard.hrh" |
|
25 #include <ccappmycardpluginrsc.rsg> |
|
26 #include <pbk2uicontrols.rsg> |
|
27 #include <data_caging_path_literals.hrh> |
|
28 #include <phonebook2.mbg> |
|
29 #include <mccappengine.h> |
|
30 #include <bautils.h> |
|
31 #include <AknsUtils.h> |
|
32 #include <AiwServiceHandler.h> |
|
33 #include <MVPbkContactLink.h> |
|
34 #include <AiwContactAssignDataTypes.h> |
|
35 #include <avkon.hrh> |
|
36 #include <aknappui.h> |
|
37 #include <CPbk2CommandHandler.h> |
|
38 #include <pbk2commands.hrh> //pbk2cmdsend |
|
39 #include <pbk2datacaging.hrh> |
|
40 #include <TPbk2ContactEditorParams.h> |
|
41 #include <CPbk2GeneralConfirmationQuery.h> |
|
42 #include <CPbk2PresentationContact.h> |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // Constants |
|
46 // --------------------------------------------------------------------------- |
|
47 |
|
48 /// MyCard own resource file |
|
49 _LIT( KMyCardResourceFileName, "ccappmycardpluginrsc.rsc" ); |
|
50 |
|
51 _LIT( KMyCardIconFileName, "\\resource\\apps\\phonebook2.mif"); |
|
52 /// Phonebook2 UI controls resource file |
|
53 _LIT( KMyCardPbk2UiControlsResFileName, "pbk2uicontrols.rsc" ); |
|
54 // pbk2 common ui |
|
55 _LIT( KPbk2CommonUiDllResFileName, "Pbk2CommonUi.rsc" ); |
|
56 // pbk2 commands |
|
57 _LIT( KPbk2CommandsDllResFileName, "Pbk2Commands.rsc"); |
|
58 |
|
59 |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CCCAppMyCardPlugin::NewL |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 CCCAppMyCardPlugin* CCCAppMyCardPlugin::NewL() |
|
66 { |
|
67 CCA_DP(KMyCardLogFile, |
|
68 CCA_L("==== NEW INSTANCE============================================")); |
|
69 CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCardPlugin::NewL()")); |
|
70 |
|
71 CCCAppMyCardPlugin* self = new ( ELeave ) CCCAppMyCardPlugin(); |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL(); |
|
74 CleanupStack::Pop( self ); |
|
75 |
|
76 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardPlugin::NewL()")); |
|
77 return self; |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CCCAppMyCardPlugin::~CCCAppMyCardPlugin |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 CCCAppMyCardPlugin::~CCCAppMyCardPlugin() |
|
85 { |
|
86 CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCardPlugin::~CCCAppMyCardPlugin()")); |
|
87 |
|
88 iPbk2UiControlResource.Close(); |
|
89 |
|
90 iCommonUiResourceFile.Close(); |
|
91 |
|
92 iCommandsResourceFile.Close(); |
|
93 |
|
94 delete iMyCard; |
|
95 |
|
96 delete iCommandHandler; |
|
97 |
|
98 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardPlugin::~CCCAppMyCardPlugin()")); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CCCAppMyCardPlugin::CCCAppMyCardPlugin() |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 CCCAppMyCardPlugin::CCCAppMyCardPlugin() : |
|
106 iPbk2UiControlResource( *iCoeEnv ), |
|
107 iCommonUiResourceFile( *iCoeEnv ), |
|
108 iCommandsResourceFile( *iCoeEnv ) |
|
109 { |
|
110 CCA_DP(KMyCardLogFile, CCA_L("CCCAppMyCardPlugin::CCCAppMyCardPlugin()")); |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // CCCAppMyCardPlugin::ConstructL |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 void CCCAppMyCardPlugin::ConstructL() |
|
118 { |
|
119 CCA_DP(KMyCardLogFile, CCA_L("CCCAppMyCardPlugin::ConstructL()")); |
|
120 // ConstructL should be as light as possible. |
|
121 |
|
122 //prepare view resources before creating command handler and mycard (was called on PreparePluginViewL before) |
|
123 PrepareViewResourcesL(); |
|
124 |
|
125 iMyCard = CCCAppMyCard::NewL( *this ); |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // CCCAppMyCardPlugin::MyCard |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 CCCAppMyCard& CCCAppMyCardPlugin::MyCard() |
|
133 { |
|
134 return *iMyCard; |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // CCCAppMyCardPlugin::PreparePluginViewL |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 void CCCAppMyCardPlugin::PreparePluginViewL( |
|
142 MCCAppPluginParameter& /*aPluginParameter*/ ) |
|
143 { |
|
144 CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCardPlugin::PreparePluginViewL()")); |
|
145 |
|
146 BaseConstructL( R_CCAMYCARD_VIEW ); |
|
147 |
|
148 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardPlugin::PreparePluginViewL()")); |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // CCCAppMyCardPlugin::DoActivateL |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CCCAppMyCardPlugin::DoActivateL( |
|
156 const TVwsViewId& aPrevViewId, |
|
157 TUid aCustomMessageId, |
|
158 const TDesC8& aCustomMessage ) |
|
159 { |
|
160 CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCardPlugin::DoActivateL()")); |
|
161 |
|
162 // Forward the activation-call to base-class |
|
163 CCCAppViewPluginAknView::DoActivateL( |
|
164 aPrevViewId, aCustomMessageId, aCustomMessage ); |
|
165 |
|
166 // Set view title |
|
167 HBufC* title = iCoeEnv->AllocReadResourceLC( R_QTN_MYCARD_TITLE ); |
|
168 SetTitleL( *title ); |
|
169 CleanupStack::PopAndDestroy( title ); |
|
170 |
|
171 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardPlugin::DoActivateL()")); |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // CCCAppMyCardPlugin::DoDeactivate |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 void CCCAppMyCardPlugin::DoDeactivate() |
|
179 { |
|
180 CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCardPlugin::DoDeactivate()")); |
|
181 |
|
182 // Forward the deactivation-call to base-class |
|
183 CCCAppViewPluginAknView::DoDeactivate(); |
|
184 |
|
185 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardPlugin::DoDeactivate()")); |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // CCCAppMyCardPlugin::ProvideBitmapL |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 void CCCAppMyCardPlugin::ProvideBitmapL( |
|
193 TCCAppIconType aIconType, |
|
194 CAknIcon& aIcon ) |
|
195 { |
|
196 CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCardPlugin::ProvideBitmapL()")); |
|
197 |
|
198 if ( ECCAppTabIcon == aIconType ) |
|
199 { |
|
200 CFbsBitmap* bmp = NULL; |
|
201 CFbsBitmap* bmpMask = NULL; |
|
202 |
|
203 // TODO: Change icon |
|
204 AknsUtils::CreateIconL( |
|
205 AknsUtils::SkinInstance(), |
|
206 KAknsIIDDefault,//todo; get a proper skin |
|
207 bmp, |
|
208 bmpMask, |
|
209 KMyCardIconFileName, |
|
210 EMbmPhonebook2Qgn_prop_pb_photo_tab3, |
|
211 EMbmPhonebook2Qgn_prop_pb_photo_tab3_mask ); |
|
212 |
|
213 aIcon.SetBitmap( bmp ); |
|
214 aIcon.SetMask( bmpMask ); |
|
215 } |
|
216 |
|
217 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardPlugin::ProvideBitmapL()")); |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------------------------- |
|
221 // CCCAppMyCardPlugin::CCCAppViewPluginBaseExtension |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 TAny* CCCAppMyCardPlugin::CCCAppViewPluginBaseExtension( TUid aExtensionUid ) |
|
225 { |
|
226 if ( aExtensionUid == KMCCAppViewPluginBaseExtension2Uid ) |
|
227 { |
|
228 return static_cast<MCCAppViewPluginBase2*>( this ); |
|
229 } |
|
230 return NULL; |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // CCCAppMyCardPlugin::DynInitMenuPaneL |
|
235 // --------------------------------------------------------------------------- |
|
236 // |
|
237 void CCCAppMyCardPlugin::DynInitMenuPaneL( |
|
238 TInt /*aResourceId*/, |
|
239 CEikMenuPane* /*aMenuPane*/ ) |
|
240 { |
|
241 // TODO: menupane handling |
|
242 } |
|
243 |
|
244 // --------------------------------------------------------------------------- |
|
245 // CCCAppMyCardPlugin::HandleCommandL |
|
246 // --------------------------------------------------------------------------- |
|
247 // |
|
248 void CCCAppMyCardPlugin::HandleCommandL( TInt aCommand ) |
|
249 { |
|
250 CCA_DP(KMyCardLogFile, |
|
251 CCA_L("->CCCAppMyCardPlugin::HandleCommandL command=%d"), aCommand ); |
|
252 |
|
253 switch( aCommand ) |
|
254 { |
|
255 case ECCAppMyCardCmdEdit: |
|
256 { |
|
257 // when editor is called via options menu, focus first field always |
|
258 EditL( 0 ); |
|
259 break; |
|
260 } |
|
261 case ECCappMyCardCmdSendVCard: |
|
262 { |
|
263 SendBusinessCardL(); |
|
264 break; |
|
265 } |
|
266 case ECCappMyCardCmdDelete: |
|
267 { |
|
268 CPbk2GeneralConfirmationQuery* query = |
|
269 CPbk2GeneralConfirmationQuery::NewL(); |
|
270 |
|
271 if ( query->ExecuteLD( iMyCard->PresentationContactL(), R_QTN_QUERY_COMMON_CONF_DELETE ) ) |
|
272 { |
|
273 iMyCard->PresentationContactL().DeleteL( *iMyCard ); |
|
274 } |
|
275 |
|
276 break; |
|
277 } |
|
278 default: |
|
279 { |
|
280 // Forward rest to base class |
|
281 CCCAppViewPluginAknView::HandleCommandL( aCommand ); |
|
282 } |
|
283 } |
|
284 |
|
285 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardPlugin::HandleCommandL()")); |
|
286 } |
|
287 |
|
288 |
|
289 // --------------------------------------------------------------------------- |
|
290 // CCCAppMyCardPlugin::EditL |
|
291 // --------------------------------------------------------------------------- |
|
292 // |
|
293 void CCCAppMyCardPlugin::EditL( TInt aFocusedFieldIndex ) |
|
294 { |
|
295 iMyCard->EditContactL( aFocusedFieldIndex ); |
|
296 } |
|
297 |
|
298 |
|
299 // --------------------------------------------------------------------------- |
|
300 // CCCAppMyCardPlugin::NewContainerL |
|
301 // --------------------------------------------------------------------------- |
|
302 // |
|
303 void CCCAppMyCardPlugin::NewContainerL() |
|
304 { |
|
305 iOwnContainer = new (ELeave) CCCAppMyCardContainer( *this ); |
|
306 iContainer = iOwnContainer; |
|
307 } |
|
308 |
|
309 // --------------------------------------------------------------------------- |
|
310 // CCCAppMyCardPlugin::PluginBusy |
|
311 // --------------------------------------------------------------------------- |
|
312 // |
|
313 TBool CCCAppMyCardPlugin::PluginBusy() |
|
314 { |
|
315 return EFalse; |
|
316 } |
|
317 |
|
318 // --------------------------------------------------------------------------- |
|
319 // CCCAppMyCardPlugin::Id |
|
320 // --------------------------------------------------------------------------- |
|
321 // |
|
322 TUid CCCAppMyCardPlugin::Id() const |
|
323 { |
|
324 return TUid::Uid( KCCAMyCardPluginImplmentationUid ); |
|
325 } |
|
326 |
|
327 // --------------------------------------------------------------------------- |
|
328 // CCCAppMyCardPlugin::PrepareViewResourcesL |
|
329 // --------------------------------------------------------------------------- |
|
330 // |
|
331 void CCCAppMyCardPlugin::PrepareViewResourcesL() |
|
332 { |
|
333 CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCardPlugin::PrepareViewResourcesL()")); |
|
334 |
|
335 // MyCard own resource file |
|
336 TFileName fileName( KDC_RESOURCE_FILES_DIR ); |
|
337 fileName.Append( KMyCardResourceFileName ); |
|
338 BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName ); |
|
339 iResourceLoader.OpenL( fileName ); |
|
340 |
|
341 /// Phonebook 2 UI controls resource |
|
342 fileName.Copy( KDC_RESOURCE_FILES_DIR ); |
|
343 fileName.Append( KMyCardPbk2UiControlsResFileName ); |
|
344 BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName ); |
|
345 iPbk2UiControlResource.OpenL( fileName ); |
|
346 |
|
347 // commands |
|
348 fileName.Copy( KDC_RESOURCE_FILES_DIR ); |
|
349 fileName.Append( KPbk2CommandsDllResFileName ); |
|
350 BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName ); |
|
351 iCommandsResourceFile.OpenL( fileName ); |
|
352 |
|
353 // common ui |
|
354 fileName.Copy( KDC_RESOURCE_FILES_DIR ); |
|
355 fileName.Append( KPbk2CommonUiDllResFileName ); |
|
356 BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName ); |
|
357 iCommonUiResourceFile.OpenL( fileName ); |
|
358 |
|
359 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardPlugin::PrepareViewResourcesL()")); |
|
360 } |
|
361 |
|
362 // --------------------------------------------------------------------------- |
|
363 // CCCAppMyCardPlugin::CommandHandlerL |
|
364 // --------------------------------------------------------------------------- |
|
365 // |
|
366 CPbk2CommandHandler* CCCAppMyCardPlugin::CommandHandlerL() |
|
367 { |
|
368 // create command handler if not created yet |
|
369 if( !iCommandHandler ) |
|
370 { |
|
371 // command handler |
|
372 iCommandHandler = CPbk2CommandHandler::NewL(); |
|
373 } |
|
374 return iCommandHandler; |
|
375 } |
|
376 |
|
377 |
|
378 // --------------------------------------------------------------------------- |
|
379 // CCCAppMyCardPlugin::SendBusinessCardL |
|
380 // --------------------------------------------------------------------------- |
|
381 // |
|
382 void CCCAppMyCardPlugin::SendBusinessCardL() |
|
383 { |
|
384 // send business card |
|
385 CommandHandlerL()->HandleCommandL( EPbk2CmdSend, *iOwnContainer, NULL ); |
|
386 } |
|
387 |
|
388 // --------------------------------------------------------------------------- |
|
389 // ProcessCommandL |
|
390 // --------------------------------------------------------------------------- |
|
391 // |
|
392 void CCCAppMyCardPlugin::ProcessCommandL(TInt aCommandId) |
|
393 { |
|
394 switch(aCommandId) |
|
395 { |
|
396 case ECCAppMyCardCmdStylusViewImageCmd: |
|
397 ViewImageCmdL(); |
|
398 break; |
|
399 |
|
400 case ECCAppMyCardCmdStylusChangeImageCmd: |
|
401 ChangeImageCmdL(); |
|
402 break; |
|
403 |
|
404 case ECCAppMyCardCmdStylusRemoveImageCmd: |
|
405 RemoveImageCmdL(); |
|
406 break; |
|
407 |
|
408 case ECCAppMyCardCmdStylusAddImageCmd: |
|
409 AddImageCmdL(); |
|
410 break; |
|
411 |
|
412 default: |
|
413 CAknView::ProcessCommandL(aCommandId); |
|
414 break; |
|
415 } |
|
416 } |
|
417 |
|
418 // --------------------------------------------------------------------------- |
|
419 // CCCAppMyCardPlugin::RemoveImageCmdL |
|
420 // --------------------------------------------------------------------------- |
|
421 // |
|
422 void CCCAppMyCardPlugin::RemoveImageCmdL() |
|
423 { |
|
424 CommandHandlerL()->HandleCommandL( EPbk2CmdRemoveImage, *iOwnContainer, NULL ); |
|
425 } |
|
426 |
|
427 // --------------------------------------------------------------------------- |
|
428 // CCCAppMyCardPlugin::AddImageCmdL |
|
429 // --------------------------------------------------------------------------- |
|
430 // |
|
431 void CCCAppMyCardPlugin::AddImageCmdL() |
|
432 { |
|
433 CommandHandlerL()->HandleCommandL( EPbk2CmdAddImage, *iOwnContainer, NULL ); |
|
434 } |
|
435 |
|
436 // --------------------------------------------------------------------------- |
|
437 // CCCAppMyCardPlugin::ViewImageCmdL |
|
438 // --------------------------------------------------------------------------- |
|
439 // |
|
440 void CCCAppMyCardPlugin::ViewImageCmdL() |
|
441 { |
|
442 CommandHandlerL()->HandleCommandL( EPbk2CmdViewImage, *iOwnContainer, NULL ); |
|
443 } |
|
444 |
|
445 // --------------------------------------------------------------------------- |
|
446 // CCCAppMyCardPlugin::ChangeImageCmdL |
|
447 // --------------------------------------------------------------------------- |
|
448 // |
|
449 void CCCAppMyCardPlugin::ChangeImageCmdL() |
|
450 { |
|
451 CommandHandlerL()->HandleCommandL( EPbk2CmdChangeImage, *iOwnContainer, NULL ); |
|
452 } |
|
453 // End of File |