|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Phonebook 2 Assign UI service AIW provider. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPbk2AiwAssignProvider.h" |
|
20 |
|
21 // Phonebook 2 |
|
22 #include "CPbk2ServerAppConnection.h" |
|
23 #include "Pbk2UIServices.hrh" |
|
24 #include <Pbk2IPCPackage.h> |
|
25 #include <Pbk2UiServicesRes.rsg> |
|
26 #include <Pbk2UIControls.rsg> |
|
27 #include <Pbk2DataCaging.hrh> |
|
28 #include <Pbk2MimeTypeHandler.h> |
|
29 #include <Pbk2InternalUID.h> |
|
30 |
|
31 // Virtual Phonebook |
|
32 #include <VPbkPublicUid.h> |
|
33 |
|
34 // System includes |
|
35 #include <AiwMenu.h> |
|
36 #include <AiwContactAssignDataTypes.h> |
|
37 #include <s32mem.h> |
|
38 #include <eikspane.h> |
|
39 #include <akntitle.h> |
|
40 #include <avkon.hrh> |
|
41 #include <featmgr.h> |
|
42 #include <aknViewAppUi.h> |
|
43 |
|
44 using namespace AiwContactAssign; |
|
45 |
|
46 /// Unnamed namespace for local definitions |
|
47 namespace { |
|
48 |
|
49 _LIT(KPbk2UiServicesDllResFileName, "Pbk2UiServicesRes.rsc"); |
|
50 _LIT(KPbk2UiControlsDllResFileName, "Pbk2UiControls.rsc"); |
|
51 |
|
52 #ifdef _DEBUG |
|
53 |
|
54 enum TPanicCode |
|
55 { |
|
56 ENullPointer, |
|
57 EInvalidArgument, |
|
58 EDataTypeNotSupported |
|
59 }; |
|
60 |
|
61 void Panic(TPanicCode aReason) |
|
62 { |
|
63 _LIT( KPanicText, "CPbk2AiwAssignProvider" ); |
|
64 User::Panic( KPanicText, aReason ); |
|
65 } |
|
66 |
|
67 #endif // _DEBUG |
|
68 |
|
69 |
|
70 /** |
|
71 * Verifies whether the given command id is handled here. |
|
72 * This should be done by AIW. |
|
73 * |
|
74 * @param aCmdId The command id to check. |
|
75 * @return ETrue if command is handled by this provider |
|
76 */ |
|
77 inline TBool IsCorrectAiwCmd( const TInt aCmdId ) |
|
78 { |
|
79 TBool ret = EFalse; |
|
80 switch ( aCmdId ) |
|
81 { |
|
82 case KAiwCmdAssign: // FALLTHROUGH |
|
83 case EPbk2AiwCmdAssign: // FALLTHROUGH |
|
84 case EPbk2AiwCmdDataSaveCreateNew: // FALLTHROUGH |
|
85 case EPbk2AiwCmdDataSaveAddToExisting: |
|
86 { |
|
87 ret = ETrue; |
|
88 break; |
|
89 } |
|
90 |
|
91 default: |
|
92 { |
|
93 // Do nothing |
|
94 break; |
|
95 } |
|
96 } |
|
97 return ret; |
|
98 } |
|
99 |
|
100 /** |
|
101 * Finds a AIW semantic id from the AIW in param list. |
|
102 * |
|
103 * @param aInParamList AIW in param list. |
|
104 * @param aSemanticId The semantic id to look for. |
|
105 * @return ETrue if found, EFalse otherwise. |
|
106 */ |
|
107 inline TBool FindSemanticId |
|
108 ( const CAiwGenericParamList& aInParamList, |
|
109 const TGenericParamId aSemanticId ) |
|
110 { |
|
111 TBool ret = EFalse; |
|
112 |
|
113 TInt index = 0; |
|
114 if ( aInParamList.FindFirst( index, aSemanticId ) ) |
|
115 { |
|
116 ret = ETrue; |
|
117 } |
|
118 |
|
119 return ret; |
|
120 } |
|
121 |
|
122 /** |
|
123 * Validates that param's data is valid |
|
124 * |
|
125 * @param aInParamList The data passed by the consumer. |
|
126 * @param aSemanticId The param which data to be validate. |
|
127 * @return ETrue if data is valid, EFalse otherwise |
|
128 */ |
|
129 inline TBool ValidateData |
|
130 ( const CAiwGenericParamList& aInParamList, |
|
131 TGenericParamId aSemanticId ) |
|
132 { |
|
133 TBool result = ETrue; |
|
134 |
|
135 // EGenericParamMIMEType param data validation |
|
136 if ( EGenericParamMIMEType == aSemanticId ) |
|
137 { |
|
138 TInt index = 0; |
|
139 |
|
140 const TAiwGenericParam* mimeTypeParam = |
|
141 aInParamList.FindFirst( index, EGenericParamMIMEType, |
|
142 EVariantTypeDesC ); |
|
143 |
|
144 TInt error = KErrNone; |
|
145 TInt mimeType = Pbk2MimeTypeHandler::EMimeTypeNotSupported; |
|
146 if ( mimeTypeParam ) |
|
147 { |
|
148 TRAP( error, |
|
149 { |
|
150 if ( mimeTypeParam->Value().AsData().Ptr() ) |
|
151 { |
|
152 // 8-bit |
|
153 mimeType = Pbk2MimeTypeHandler::MapMimeTypeL |
|
154 ( mimeTypeParam->Value().AsData() ); |
|
155 } |
|
156 else if ( mimeTypeParam->Value().AsDes().Ptr() ) |
|
157 { |
|
158 // 16-bit |
|
159 mimeType = Pbk2MimeTypeHandler::MapMimeTypeL |
|
160 ( mimeTypeParam->Value().AsDes() ); |
|
161 } |
|
162 } ); // TRAP |
|
163 } |
|
164 |
|
165 // No MIME type found if leaves with KErrNotFound. |
|
166 // Not supported type if mimeType is not found. |
|
167 if ( error == KErrNotFound || |
|
168 Pbk2MimeTypeHandler::EMimeTypeNotSupported == mimeType ) |
|
169 { |
|
170 result = EFalse; |
|
171 } |
|
172 } |
|
173 |
|
174 return result; |
|
175 } |
|
176 |
|
177 /** |
|
178 * Validates that consumer passed all required data. |
|
179 * Checks also if required param EGenericParamMIMEType data is valid. |
|
180 * If invalid data is given leave KErrArgument will occur. |
|
181 * |
|
182 * @param aInParamList The data passed by the consumer. |
|
183 * @return EGenericParamUnspecified if no valid data is found, |
|
184 * AIW semantic id of found data otherwise. |
|
185 */ |
|
186 inline TGenericParamId ValidateParams |
|
187 ( const CAiwGenericParamList& aInParamList ) |
|
188 { |
|
189 TGenericParamId ret = EGenericParamUnspecified; |
|
190 |
|
191 if ( FindSemanticId( aInParamList, EGenericParamPhoneNumber ) ) |
|
192 { |
|
193 ret = EGenericParamPhoneNumber; |
|
194 } |
|
195 else if ( FindSemanticId( aInParamList, EGenericParamEmailAddress ) ) |
|
196 { |
|
197 ret = EGenericParamEmailAddress; |
|
198 } |
|
199 else if ( FindSemanticId( aInParamList, EGenericParamSIPAddress ) ) |
|
200 { |
|
201 ret = EGenericParamSIPAddress; |
|
202 } |
|
203 else if ( FindSemanticId( aInParamList, EGenericParamURL ) ) |
|
204 { |
|
205 ret = EGenericParamURL; |
|
206 } |
|
207 else if ( FindSemanticId( aInParamList, EGenericParamWVID ) ) |
|
208 { |
|
209 ret = EGenericParamWVID; |
|
210 } |
|
211 else if ( FindSemanticId( aInParamList, EGenericParamSpeedDialIndex ) ) |
|
212 { |
|
213 ret = EGenericParamSpeedDialIndex; |
|
214 } |
|
215 else if ( FindSemanticId( aInParamList, EGenericParamXSpId ) ) |
|
216 { |
|
217 ret = EGenericParamXSpId; |
|
218 } |
|
219 else if ( FindSemanticId( aInParamList, EGenericParamContactItem ) ) |
|
220 { |
|
221 ret = EGenericParamContactItem; |
|
222 } |
|
223 if ( ret == EGenericParamUnspecified ) |
|
224 { |
|
225 // The in param list must have a MIME type with the data and file name |
|
226 if ( FindSemanticId( aInParamList, EGenericParamMIMEType ) && |
|
227 ValidateData( aInParamList, EGenericParamMIMEType ) ) |
|
228 { |
|
229 if ( FindSemanticId( aInParamList, EGenericParamFile ) ) |
|
230 { |
|
231 // In this case, return EGenericParamFile |
|
232 ret = EGenericParamFile; |
|
233 } |
|
234 } |
|
235 } |
|
236 |
|
237 return ret; |
|
238 } |
|
239 |
|
240 /** |
|
241 * Selects correct address select selector matching the passed parameters. |
|
242 * |
|
243 * @param aInParamList Parameter list. |
|
244 * @return Selector resource id. |
|
245 */ |
|
246 TInt SelectSelectorResourceIdFromParams |
|
247 ( const CAiwGenericParamList& aInParamList ) |
|
248 { |
|
249 TInt resourceId = KErrNotFound; |
|
250 |
|
251 if ( FindSemanticId( aInParamList, EGenericParamPhoneNumber ) ) |
|
252 { |
|
253 if( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) ) |
|
254 { |
|
255 resourceId = R_PBK2_AIW_PHONENUMBER_SELECTOR_VOIP; |
|
256 } |
|
257 else |
|
258 { |
|
259 resourceId = R_PBK2_AIW_PHONENUMBER_SELECTOR; |
|
260 } |
|
261 } |
|
262 else if ( FindSemanticId( aInParamList, EGenericParamEmailAddress ) ) |
|
263 { |
|
264 if( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) ) |
|
265 { |
|
266 resourceId = R_PBK2_AIW_EMAIL_SELECTOR_VOIP; |
|
267 } |
|
268 else |
|
269 { |
|
270 resourceId = R_PBK2_AIW_EMAIL_SELECTOR; |
|
271 } |
|
272 } |
|
273 else if ( FindSemanticId( aInParamList, EGenericParamSIPAddress ) ) |
|
274 { |
|
275 if( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) ) |
|
276 { |
|
277 resourceId = R_PBK2_AIW_SIP_SELECTOR_VOIP; |
|
278 } |
|
279 else |
|
280 { |
|
281 resourceId = R_PBK2_AIW_SIP_SELECTOR; |
|
282 } |
|
283 } |
|
284 else if ( FindSemanticId( aInParamList, EGenericParamURL ) ) |
|
285 { |
|
286 resourceId = R_PBK2_AIW_URL_SELECTOR; |
|
287 } |
|
288 else if ( FindSemanticId( aInParamList, EGenericParamWVID ) ) |
|
289 { |
|
290 // Not supported yet |
|
291 } |
|
292 else if ( FindSemanticId( aInParamList, EGenericParamDateTime ) ) |
|
293 { |
|
294 // Not supported yet |
|
295 } |
|
296 else if ( FindSemanticId( aInParamList, EGenericParamXSpId ) ) |
|
297 { |
|
298 resourceId = R_PBK2_AIW_IMPP_SELECTOR; |
|
299 } |
|
300 else |
|
301 { |
|
302 TInt index = 0; |
|
303 |
|
304 // Lets then try MIME type param |
|
305 const TAiwGenericParam* mimeTypeParam = |
|
306 aInParamList.FindFirst( index, EGenericParamMIMEType, |
|
307 EVariantTypeDesC ); |
|
308 |
|
309 if ( mimeTypeParam ) |
|
310 { |
|
311 // If MIME type is specified, then the selector resource |
|
312 // depends on the type of MIME |
|
313 TInt mimeType( 0 ); |
|
314 if ( mimeTypeParam->Value().AsData().Ptr() ) |
|
315 { |
|
316 // 8-bit |
|
317 mimeType = Pbk2MimeTypeHandler::MapMimeTypeL |
|
318 ( mimeTypeParam->Value().AsData() ); |
|
319 } |
|
320 else if ( mimeTypeParam->Value().AsDes().Ptr() ) |
|
321 { |
|
322 // 16-bit |
|
323 mimeType = Pbk2MimeTypeHandler::MapMimeTypeL |
|
324 ( mimeTypeParam->Value().AsDes() ); |
|
325 } |
|
326 |
|
327 switch ( mimeType ) |
|
328 { |
|
329 case Pbk2MimeTypeHandler::EMimeTypeImage: |
|
330 { |
|
331 resourceId = R_PBK2_AIW_THUMBNAIL_SELECTOR; |
|
332 break; |
|
333 } |
|
334 case Pbk2MimeTypeHandler::EMimeTypeAudio: // FALLTHROUGH |
|
335 case Pbk2MimeTypeHandler::EMimeTypeVideo: |
|
336 { |
|
337 resourceId = R_PBK2_AIW_RINGTONE_SELECTOR; |
|
338 break; |
|
339 } |
|
340 default: |
|
341 { |
|
342 // Do nothing |
|
343 break; |
|
344 } |
|
345 } |
|
346 } |
|
347 } |
|
348 |
|
349 return resourceId; |
|
350 } |
|
351 |
|
352 /** |
|
353 * Selects correct contact view filter selector matching |
|
354 * the passed parameters. |
|
355 * |
|
356 * @param aInParamList Parameter list. |
|
357 * @return Selector resource id. |
|
358 */ |
|
359 TInt SelectFilterResourceIdFromParams |
|
360 ( const CAiwGenericParamList& aInParamList ) |
|
361 { |
|
362 TInt resourceId = KErrNotFound; |
|
363 |
|
364 if ( FindSemanticId( aInParamList, EGenericParamSpeedDialIndex ) ) |
|
365 { |
|
366 resourceId = R_PHONEBOOK2_PHONENUMBER_SELECTOR; |
|
367 } |
|
368 |
|
369 return resourceId; |
|
370 } |
|
371 |
|
372 } /// namespace |
|
373 |
|
374 // -------------------------------------------------------------------------- |
|
375 // CPbk2AiwAssignProvider::CPbk2AiwAssignProvider |
|
376 // -------------------------------------------------------------------------- |
|
377 // |
|
378 CPbk2AiwAssignProvider::CPbk2AiwAssignProvider() |
|
379 : iUiServicesResourceFile( *CCoeEnv::Static() ) |
|
380 { |
|
381 } |
|
382 |
|
383 // -------------------------------------------------------------------------- |
|
384 // CPbk2AiwAssignProvider::~CPbk2AiwAssignProvider |
|
385 // -------------------------------------------------------------------------- |
|
386 // |
|
387 CPbk2AiwAssignProvider::~CPbk2AiwAssignProvider() |
|
388 { |
|
389 delete iConnection; |
|
390 delete iEventParamList; |
|
391 delete iDataPackage; |
|
392 delete iConfigurationPackage; |
|
393 delete iInstructionsPackage; |
|
394 iUiServicesResourceFile.Close(); |
|
395 FeatureManager::UnInitializeLib(); |
|
396 } |
|
397 |
|
398 // -------------------------------------------------------------------------- |
|
399 // CPbk2AiwAssignProvider::NewL |
|
400 // -------------------------------------------------------------------------- |
|
401 // |
|
402 CPbk2AiwAssignProvider* CPbk2AiwAssignProvider::NewL() |
|
403 { |
|
404 CPbk2AiwAssignProvider* self = new ( ELeave) CPbk2AiwAssignProvider; |
|
405 CleanupStack::PushL( self ); |
|
406 self->ConstructL(); |
|
407 CleanupStack::Pop( self ); |
|
408 return self; |
|
409 } |
|
410 |
|
411 // -------------------------------------------------------------------------- |
|
412 // CPbk2AiwAssignProvider::ConstructL |
|
413 // -------------------------------------------------------------------------- |
|
414 // |
|
415 void CPbk2AiwAssignProvider::ConstructL() |
|
416 { |
|
417 iUiServicesResourceFile.OpenL(KPbk2RomFileDrive, |
|
418 KDC_RESOURCE_FILES_DIR, KPbk2UiServicesDllResFileName); |
|
419 FeatureManager::InitializeLibL(); |
|
420 } |
|
421 |
|
422 // -------------------------------------------------------------------------- |
|
423 // CPbk2AiwAssignProvider::InitializeMenuPaneL |
|
424 // -------------------------------------------------------------------------- |
|
425 // |
|
426 void CPbk2AiwAssignProvider::InitializeMenuPaneL |
|
427 ( CAiwMenuPane& aMenuPane, TInt aIndex, |
|
428 TInt /*aCascadeId*/, const CAiwGenericParamList& aInParamList) |
|
429 { |
|
430 TAiwGenericParam param = ValidateParams(aInParamList); |
|
431 if (param != EGenericParamUnspecified) |
|
432 { |
|
433 // Initialize with the default menu |
|
434 TInt menuResourceId = R_PBK2_AIW_ASSIGN; |
|
435 |
|
436 CreateInstructionPackageL( aInParamList ); |
|
437 |
|
438 if (iInstructionsPackage) |
|
439 { |
|
440 TInt version = TAiwContactAssignDataBase:: |
|
441 AssignDataTypeFromBuffer( *iInstructionsPackage ); |
|
442 if (version == EAiwMultipleContactAssignV1) |
|
443 { |
|
444 // Multi assign has always just one menu option, |
|
445 // and it has already been set |
|
446 } |
|
447 else if (version == EAiwSingleContactAssignV1) |
|
448 { |
|
449 // Single assign defaults to R_PBK2_AIW_ADD_TO_CONTACTS, |
|
450 // but if there is a raised EUseSimpleMenu flag |
|
451 // then we show the R_PBK2_AIW_ASSIGN menu |
|
452 TAiwSingleContactAssignDataV1Pckg data; |
|
453 data.Copy( *iInstructionsPackage ); |
|
454 TUint assignFlags = data().Flags(); |
|
455 if ( !( assignFlags & EUseSimpleMenu ) ) |
|
456 { |
|
457 if (param == EGenericParamXSpId) |
|
458 { |
|
459 menuResourceId = R_PBK2_AIW_ADD_TO_CONTACTS_XSP; |
|
460 } |
|
461 else |
|
462 { |
|
463 menuResourceId = R_PBK2_AIW_ADD_TO_CONTACTS; |
|
464 } |
|
465 } |
|
466 } |
|
467 else |
|
468 { |
|
469 User::Leave( KErrArgument ); |
|
470 } |
|
471 } |
|
472 |
|
473 // Show the menu |
|
474 TResourceReader reader; |
|
475 CCoeEnv::Static()->CreateResourceReaderLC |
|
476 (reader, menuResourceId); |
|
477 aMenuPane.AddMenuItemsL(reader, KAiwCmdAssign, aIndex); |
|
478 CleanupStack::PopAndDestroy(); // reader |
|
479 } |
|
480 } |
|
481 |
|
482 // -------------------------------------------------------------------------- |
|
483 // CPbk2AiwAssignProvider::HandleMenuCmdL |
|
484 // -------------------------------------------------------------------------- |
|
485 // |
|
486 void CPbk2AiwAssignProvider::HandleMenuCmdL |
|
487 ( TInt aMenuCmdId, const CAiwGenericParamList& aInParamList, |
|
488 CAiwGenericParamList& aOutParamList, |
|
489 TUint aCmdOptions, const MAiwNotifyCallback* aCallback ) |
|
490 { |
|
491 // Route to HandleServiceCmdL |
|
492 HandleServiceCmdL( aMenuCmdId, aInParamList, |
|
493 aOutParamList, aCmdOptions, aCallback ); |
|
494 } |
|
495 |
|
496 // -------------------------------------------------------------------------- |
|
497 // CPbk2AiwAssignProvider::InitialiseL |
|
498 // -------------------------------------------------------------------------- |
|
499 // |
|
500 void CPbk2AiwAssignProvider::InitialiseL |
|
501 ( MAiwNotifyCallback& /*aFrameworkCallback*/, |
|
502 const RCriteriaArray& /*aInterest*/ ) |
|
503 { |
|
504 // Nothing needs to be done |
|
505 } |
|
506 |
|
507 // -------------------------------------------------------------------------- |
|
508 // CPbk2AiwAssignProvider::HandleServiceCmdL |
|
509 // -------------------------------------------------------------------------- |
|
510 // |
|
511 void CPbk2AiwAssignProvider::HandleServiceCmdL |
|
512 ( const TInt& aCmdId, const CAiwGenericParamList& aInParamList, |
|
513 CAiwGenericParamList& /*aOutParamList*/, |
|
514 TUint aCmdOptions, const MAiwNotifyCallback* aCallback ) |
|
515 { |
|
516 if ( IsCorrectAiwCmd( aCmdId ) ) |
|
517 { |
|
518 if ( !iConnection ) |
|
519 { |
|
520 iConnection = CPbk2ServerAppConnection::NewL( *this ); |
|
521 } |
|
522 else if( iConnection->IsActive() ) |
|
523 { |
|
524 if ( aCmdOptions & KAiwOptCancel ) |
|
525 { |
|
526 // Client wants to cancel existing service |
|
527 iConnection->CancelAssign(); |
|
528 } |
|
529 |
|
530 // Request is already active for the same client, do nothing |
|
531 // as Phonebook supports only one request per client at a time. |
|
532 return; |
|
533 } |
|
534 |
|
535 if ( !iEventParamList ) |
|
536 { |
|
537 iEventParamList = CAiwGenericParamList::NewL(); |
|
538 } |
|
539 |
|
540 TGenericParamId semanticId = ValidateParams( aInParamList ); |
|
541 iCallback = aCallback; |
|
542 |
|
543 // Create IPC packages |
|
544 CreateInstructionPackageL( aInParamList ); |
|
545 ValidateInstructionPackageL(); |
|
546 ValidateMenuServiceL( aCmdId ); |
|
547 CreateConfigurationPackageL( aInParamList ); |
|
548 |
|
549 if ( semanticId == EGenericParamSpeedDialIndex ) |
|
550 { |
|
551 LaunchAttributeAssignL( aInParamList, semanticId ); |
|
552 } |
|
553 else |
|
554 { |
|
555 LaunchDataAssignL( aInParamList, semanticId ); |
|
556 } |
|
557 } |
|
558 } |
|
559 |
|
560 // -------------------------------------------------------------------------- |
|
561 // CPbk2AiwAssignProvider::OperationCompleteL |
|
562 // -------------------------------------------------------------------------- |
|
563 // |
|
564 void CPbk2AiwAssignProvider::OperationCompleteL |
|
565 ( const TDesC8& aContactLinks, TInt aExtraResultData, |
|
566 const TDesC& /*aField*/ ) |
|
567 { |
|
568 iEventParamList->Reset(); |
|
569 iEventParamList->AppendL( |
|
570 TAiwGenericParam( EGenericParamContactLinkArray, |
|
571 TAiwVariant( aContactLinks ) ) ); |
|
572 |
|
573 // aExtraResultData contains index of focused field from editor |
|
574 // this is used in cca details view. |
|
575 // todo: would it be better to add a new aiw semantic id instead of EGenericParamContactItem? |
|
576 iEventParamList->AppendL( |
|
577 TAiwGenericParam( EGenericParamContactItem, |
|
578 TAiwVariant( aExtraResultData ))); |
|
579 |
|
580 if (iCallback) |
|
581 { |
|
582 // Must cast this because of AIW design error |
|
583 const_cast<MAiwNotifyCallback*>(iCallback)->HandleNotifyL |
|
584 ( KAiwCmdAssign, KAiwEventCompleted, *iEventParamList, |
|
585 *iInParamList ); |
|
586 } |
|
587 } |
|
588 |
|
589 // -------------------------------------------------------------------------- |
|
590 // CPbk2AiwAssignProvider::OperationCanceledL |
|
591 // -------------------------------------------------------------------------- |
|
592 // |
|
593 void CPbk2AiwAssignProvider::OperationCanceledL() |
|
594 { |
|
595 iEventParamList->Reset(); |
|
596 if (iCallback) |
|
597 { |
|
598 // Must cast this because of AIW design error |
|
599 const_cast<MAiwNotifyCallback*>(iCallback)->HandleNotifyL |
|
600 ( KAiwCmdAssign, KAiwEventCanceled, *iEventParamList, |
|
601 *iInParamList ); |
|
602 } |
|
603 } |
|
604 |
|
605 // -------------------------------------------------------------------------- |
|
606 // CPbk2AiwAssignProvider::OperationErrorL |
|
607 // -------------------------------------------------------------------------- |
|
608 // |
|
609 void CPbk2AiwAssignProvider::OperationErrorL( TInt aError ) |
|
610 { |
|
611 iEventParamList->Reset(); |
|
612 iEventParamList->AppendL( |
|
613 TAiwGenericParam( EGenericParamError, |
|
614 TAiwVariant( aError ) ) ); |
|
615 |
|
616 if ( iCallback ) |
|
617 { |
|
618 // Must cast this because of AIW design error |
|
619 const_cast<MAiwNotifyCallback*>( iCallback )->HandleNotifyL |
|
620 ( KAiwCmdAssign, KAiwEventError, *iEventParamList, |
|
621 *iInParamList ); |
|
622 } |
|
623 } |
|
624 |
|
625 // -------------------------------------------------------------------------- |
|
626 // CPbk2AiwAssignProvider::OkToExitL |
|
627 // -------------------------------------------------------------------------- |
|
628 // |
|
629 TBool CPbk2AiwAssignProvider::OkToExitL |
|
630 ( TInt /*aCommandId*/, TPbk2ExitCommandParams aExitParameter ) |
|
631 { |
|
632 TBool okToExit = ETrue; |
|
633 |
|
634 if ( iCallback ) |
|
635 { |
|
636 iEventParamList->Reset(); |
|
637 iEventParamList->AppendL( |
|
638 TAiwGenericParam( EGenericParamApplication, |
|
639 TAiwVariant( aExitParameter ) ) ); |
|
640 |
|
641 // Must cast this because of AIW design error |
|
642 okToExit = const_cast<MAiwNotifyCallback*>( iCallback ) |
|
643 ->HandleNotifyL( KAiwCmdAssign, KAiwEventQueryExit, |
|
644 *iEventParamList, *iInParamList ); |
|
645 } |
|
646 |
|
647 return okToExit; |
|
648 } |
|
649 |
|
650 // -------------------------------------------------------------------------- |
|
651 // CPbk2AiwAssignProvider::AcceptSelectionL |
|
652 // -------------------------------------------------------------------------- |
|
653 // |
|
654 TBool CPbk2AiwAssignProvider::AcceptSelectionL |
|
655 ( TInt /*aNumberOfSelectedContacts*/, HBufC8& /*aContactLink*/ ) |
|
656 { |
|
657 // Assign service does not contain support |
|
658 // for verification of the selection |
|
659 return ETrue; |
|
660 } |
|
661 |
|
662 // -------------------------------------------------------------------------- |
|
663 // CPbk2AiwAssignProvider::PackParameterToBufferL |
|
664 // -------------------------------------------------------------------------- |
|
665 // |
|
666 HBufC8* CPbk2AiwAssignProvider::PackParameterToBufferL |
|
667 ( TGenericParamId aParamId, |
|
668 const CAiwGenericParamList& aInParamList) const |
|
669 { |
|
670 HBufC8* result = NULL; |
|
671 |
|
672 TInt paramIndex = 0; |
|
673 const TAiwGenericParam* paramData = |
|
674 aInParamList.FindFirst( paramIndex, aParamId ); |
|
675 |
|
676 if ( paramData && paramData->Value().AsData().Ptr() ) |
|
677 { |
|
678 result = paramData->Value().AsData().AllocL(); |
|
679 } |
|
680 else if ( paramData && paramData->Value().AsDes().Ptr() ) |
|
681 { |
|
682 // Data was given as 16-bit, transform it into 8-bit |
|
683 const TInt size( paramData->Value().AsDes().Size() ); |
|
684 result = HBufC8::NewL( size ); |
|
685 result->Des().Copy( paramData->Value().AsDes() ); |
|
686 } |
|
687 |
|
688 return result; |
|
689 } |
|
690 |
|
691 // -------------------------------------------------------------------------- |
|
692 // CPbk2AiwAssignProvider::PackParameterToBuffer16L |
|
693 // -------------------------------------------------------------------------- |
|
694 // |
|
695 HBufC16* CPbk2AiwAssignProvider::PackParameterToBuffer16L |
|
696 ( TGenericParamId aParamId, |
|
697 const CAiwGenericParamList& aInParamList ) const |
|
698 { |
|
699 HBufC16* result = NULL; |
|
700 |
|
701 TInt paramIndex = 0; |
|
702 const TAiwGenericParam* paramData = |
|
703 aInParamList.FindFirst(paramIndex, aParamId); |
|
704 |
|
705 if ( paramData && paramData->Value().AsData().Ptr() ) |
|
706 { |
|
707 // Data was given as 8-bit, transform it into 16-bit |
|
708 const TInt size( paramData->Value().AsData().Size() ); |
|
709 result = HBufC::NewL( size ); |
|
710 result->Des().Copy( paramData->Value().AsData() ); |
|
711 } |
|
712 else if ( paramData && paramData->Value().AsDes().Ptr() ) |
|
713 { |
|
714 result = paramData->Value().AsDes().AllocL(); |
|
715 } |
|
716 |
|
717 return result; |
|
718 } |
|
719 |
|
720 // -------------------------------------------------------------------------- |
|
721 // CPbk2AiwAssignProvider::PackSelectorToBufferL |
|
722 // -------------------------------------------------------------------------- |
|
723 // |
|
724 HBufC8* CPbk2AiwAssignProvider::PackSelectorToBufferL |
|
725 ( const CAiwGenericParamList& aInParamList ) const |
|
726 { |
|
727 HBufC8* result = NULL; |
|
728 |
|
729 TInt resourceId = SelectSelectorResourceIdFromParams( aInParamList ); |
|
730 if ( resourceId != KErrNotFound ) |
|
731 { |
|
732 // Construct a resource buffer pointed to |
|
733 // VPBK_FIELD_TYPE_SELECTOR resource, which will |
|
734 // contain the suitable fields for the passed data |
|
735 RFs fs; |
|
736 User::LeaveIfError( fs.Connect() ); |
|
737 CleanupClosePushL( fs ); |
|
738 |
|
739 RPbk2LocalizedResourceFile resFile = |
|
740 RPbk2LocalizedResourceFile( &fs ); |
|
741 resFile.OpenLC( KPbk2RomFileDrive, |
|
742 KDC_RESOURCE_FILES_DIR, KPbk2UiServicesDllResFileName ); |
|
743 result = resFile.AllocReadLC( resourceId ); |
|
744 CleanupStack::Pop(); // result |
|
745 CleanupStack::PopAndDestroy(2); // resFile, fs |
|
746 } |
|
747 |
|
748 return result; |
|
749 } |
|
750 |
|
751 // -------------------------------------------------------------------------- |
|
752 // CPbk2AiwAssignProvider::PackFilterToBufferL |
|
753 // -------------------------------------------------------------------------- |
|
754 // |
|
755 HBufC8* CPbk2AiwAssignProvider::PackFilterToBufferL |
|
756 ( const CAiwGenericParamList& aInParamList ) const |
|
757 { |
|
758 HBufC8* result = NULL; |
|
759 |
|
760 TInt resourceId = SelectFilterResourceIdFromParams( aInParamList ); |
|
761 if ( resourceId != KErrNotFound ) |
|
762 { |
|
763 // Construct a resource buffer pointed to |
|
764 // VPBK_FIELD_TYPE_SELECTOR resource, which will |
|
765 // contain the suitable fields for the passed data |
|
766 RFs fs; |
|
767 User::LeaveIfError( fs.Connect() ); |
|
768 CleanupClosePushL( fs ); |
|
769 |
|
770 RPbk2LocalizedResourceFile resFile = |
|
771 RPbk2LocalizedResourceFile( &fs ); |
|
772 resFile.OpenLC( KPbk2RomFileDrive, |
|
773 KDC_RESOURCE_FILES_DIR, KPbk2UiControlsDllResFileName ); |
|
774 result = resFile.AllocReadLC( resourceId ); |
|
775 CleanupStack::Pop(); // result |
|
776 CleanupStack::PopAndDestroy(2); // resFile, fs |
|
777 } |
|
778 |
|
779 return result; |
|
780 } |
|
781 |
|
782 // -------------------------------------------------------------------------- |
|
783 // CPbk2AiwAssignProvider::CreateDataPackageL |
|
784 // -------------------------------------------------------------------------- |
|
785 // |
|
786 void CPbk2AiwAssignProvider::CreateDataPackageL |
|
787 ( const CAiwGenericParamList& aInParamList, |
|
788 const TGenericParamId aSemanticId ) |
|
789 { |
|
790 // MIME type |
|
791 HBufC8* mimeTypeBuffer = PackParameterToBufferL |
|
792 ( EGenericParamMIMEType, aInParamList ); |
|
793 CleanupStack::PushL( mimeTypeBuffer ); |
|
794 |
|
795 // The data to assign, if any |
|
796 HBufC16* dataBuffer = NULL; |
|
797 HBufC16* indexBuffer = NULL; |
|
798 if ( aSemanticId == EGenericParamXSpId) |
|
799 { |
|
800 dataBuffer = PackImppParametersToBufferL(aInParamList); |
|
801 } |
|
802 else if ( aSemanticId == EGenericParamContactItem ) |
|
803 { |
|
804 // TODO: get index from aInParamList AsTInt32() |
|
805 indexBuffer = PackParameterToBuffer16L( aSemanticId, aInParamList ); |
|
806 } |
|
807 else if ( aSemanticId != EGenericParamUnspecified ) |
|
808 { |
|
809 dataBuffer = PackParameterToBuffer16L( aSemanticId, aInParamList ); |
|
810 } |
|
811 CleanupStack::PushL( dataBuffer ); |
|
812 CleanupStack::PushL( indexBuffer ); |
|
813 |
|
814 TInt length = Pbk2IPCPackage::CountPackageSize( mimeTypeBuffer ); |
|
815 length += Pbk2IPCPackage::CountPackageSize( dataBuffer ); |
|
816 length += Pbk2IPCPackage::CountPackageSize( indexBuffer ); |
|
817 |
|
818 delete iDataPackage; |
|
819 iDataPackage = NULL; |
|
820 iDataPackage = HBufC8::NewL( length ); |
|
821 TPtr8 bufferPtr( iDataPackage->Des() ); |
|
822 |
|
823 RDesWriteStream writeStream( bufferPtr ); |
|
824 writeStream.PushL(); |
|
825 Pbk2IPCPackage::ExternalizeL( mimeTypeBuffer, writeStream ); |
|
826 Pbk2IPCPackage::ExternalizeL( dataBuffer, writeStream ); |
|
827 Pbk2IPCPackage::ExternalizeL( indexBuffer, writeStream ); |
|
828 writeStream.CommitL(); |
|
829 |
|
830 CleanupStack::PopAndDestroy( &writeStream ); |
|
831 CleanupStack::PopAndDestroy( 3 ); // dataBuffer, mimeTypeBuffer, indexbuffer |
|
832 } |
|
833 |
|
834 // -------------------------------------------------------------------------- |
|
835 // CPbk2AiwAssignProvider::CreateAttributePackageL |
|
836 // -------------------------------------------------------------------------- |
|
837 // |
|
838 TPbk2AttributeAssignData CPbk2AiwAssignProvider::CreateAttributePackageL |
|
839 ( const CAiwGenericParamList& aInParamList, |
|
840 const TGenericParamId aSemanticId ) |
|
841 { |
|
842 TPbk2AttributeAssignData ret; |
|
843 ret.iAttributeUid = TUid::Uid( KEPOCNullUID ); |
|
844 ret.iAttributeValue = KErrNotFound; |
|
845 |
|
846 switch ( aSemanticId ) |
|
847 { |
|
848 case EGenericParamSpeedDialIndex: |
|
849 { |
|
850 TInt speedDialIndex = KErrNotFound; |
|
851 TInt paramIndex = 0; |
|
852 |
|
853 const TAiwGenericParam* paramData = |
|
854 aInParamList.FindFirst( paramIndex, aSemanticId ); |
|
855 |
|
856 if ( paramData ) |
|
857 { |
|
858 speedDialIndex = paramData->Value().AsTInt32(); |
|
859 } |
|
860 |
|
861 ret.iAttributeUid = |
|
862 TUid::Uid( KVPbkSpeedDialAttributeImplementationUID ); |
|
863 ret.iAttributeValue = speedDialIndex; |
|
864 break; |
|
865 } |
|
866 |
|
867 default: |
|
868 { |
|
869 __ASSERT_DEBUG( EFalse, Panic( EInvalidArgument ) ); |
|
870 break; |
|
871 } |
|
872 }; |
|
873 |
|
874 return ret; |
|
875 } |
|
876 |
|
877 // -------------------------------------------------------------------------- |
|
878 // CPbk2AiwAssignProvider::CreateConfigurationPackageL |
|
879 // -------------------------------------------------------------------------- |
|
880 // |
|
881 void CPbk2AiwAssignProvider::CreateConfigurationPackageL |
|
882 ( const CAiwGenericParamList& aInParamList ) |
|
883 { |
|
884 // Store URIs |
|
885 HBufC8* storeUriBuffer = PackParameterToBufferL |
|
886 ( EGenericParamContactStoreUriArray, aInParamList ); |
|
887 CleanupStack::PushL( storeUriBuffer ); |
|
888 |
|
889 // Contact links |
|
890 HBufC8* linkBuffer = PackParameterToBufferL |
|
891 ( EGenericParamContactLinkArray, aInParamList ); |
|
892 CleanupStack::PushL( linkBuffer ); |
|
893 |
|
894 // Field type selector |
|
895 HBufC8* selectorBuffer = PackSelectorToBufferL( aInParamList ); |
|
896 CleanupStack::PushL( selectorBuffer ); |
|
897 |
|
898 // Contact view filter |
|
899 HBufC8* viewFilterBuffer = PackFilterToBufferL( aInParamList ); |
|
900 CleanupStack::PushL( viewFilterBuffer ); |
|
901 |
|
902 // Title pane |
|
903 HBufC* titlePaneText = ClientTitlePaneL(); |
|
904 CleanupStack::PushL( titlePaneText ); |
|
905 |
|
906 HBufC* orientationType = ClientOrientation(); |
|
907 CleanupStack::PushL( orientationType ); |
|
908 TInt length = Pbk2IPCPackage::CountPackageSize( storeUriBuffer ); |
|
909 length += Pbk2IPCPackage::CountPackageSize( linkBuffer ); |
|
910 length += Pbk2IPCPackage::CountPackageSize( selectorBuffer ); |
|
911 length += Pbk2IPCPackage::CountPackageSize( viewFilterBuffer ); |
|
912 length += Pbk2IPCPackage::CountPackageSize( titlePaneText ); |
|
913 length += Pbk2IPCPackage::CountPackageSize( orientationType ); |
|
914 |
|
915 delete iConfigurationPackage; |
|
916 iConfigurationPackage = NULL; |
|
917 iConfigurationPackage = HBufC8::NewL( length ); |
|
918 TPtr8 bufferPtr( iConfigurationPackage->Des() ); |
|
919 |
|
920 RDesWriteStream writeStream( bufferPtr ); |
|
921 writeStream.PushL(); |
|
922 Pbk2IPCPackage::ExternalizeL( storeUriBuffer, writeStream ); |
|
923 Pbk2IPCPackage::ExternalizeL( linkBuffer, writeStream ); |
|
924 Pbk2IPCPackage::ExternalizeL( selectorBuffer, writeStream ); |
|
925 Pbk2IPCPackage::ExternalizeL( viewFilterBuffer, writeStream ); |
|
926 Pbk2IPCPackage::ExternalizeL( titlePaneText, writeStream ); |
|
927 Pbk2IPCPackage::ExternalizeL( orientationType, writeStream ); |
|
928 writeStream.CommitL(); |
|
929 |
|
930 CleanupStack::PopAndDestroy( &writeStream ); |
|
931 CleanupStack::PopAndDestroy( 6 ); // orientationType, titlePaneText, |
|
932 // viewFilterBuffer, selectorBuffer, |
|
933 // linkBuffer, storeUriBuffer |
|
934 } |
|
935 |
|
936 // -------------------------------------------------------------------------- |
|
937 // CPbk2AiwAssignProvider::CreateInstructionPackageL |
|
938 // -------------------------------------------------------------------------- |
|
939 // |
|
940 void CPbk2AiwAssignProvider::CreateInstructionPackageL |
|
941 ( const CAiwGenericParamList& aInParamList ) |
|
942 { |
|
943 delete iInstructionsPackage; |
|
944 iInstructionsPackage = NULL; |
|
945 iInstructionsPackage = PackParameterToBufferL |
|
946 ( EGenericParamContactAssignData, aInParamList ); |
|
947 } |
|
948 |
|
949 // -------------------------------------------------------------------------- |
|
950 // CPbk2AiwAssignProvider::ValidateInstructionPackageL |
|
951 // -------------------------------------------------------------------------- |
|
952 // |
|
953 void CPbk2AiwAssignProvider::ValidateInstructionPackageL() |
|
954 { |
|
955 if ( iInstructionsPackage ) |
|
956 { |
|
957 // Version check |
|
958 TInt version = TAiwContactAssignDataBase:: |
|
959 AssignDataTypeFromBuffer( *iInstructionsPackage ); |
|
960 if ( version == EAiwContactAssignDataTypeNotDefined ) |
|
961 { |
|
962 User::Leave( KErrArgument ); |
|
963 } |
|
964 |
|
965 switch( version ) |
|
966 { |
|
967 case EAiwSingleContactAssignV1: |
|
968 { |
|
969 // Nothing to validate since for example editor can be |
|
970 // on/off and similarly with new contact creation both |
|
971 // choises on/off are supported |
|
972 break; |
|
973 } |
|
974 |
|
975 case EAiwMultipleContactAssignV1: |
|
976 { |
|
977 TAiwMultipleContactAssignDataV1Pckg dataPckg; |
|
978 |
|
979 // Reconstruct the instructions |
|
980 dataPckg.Copy( iInstructionsPackage->Ptr(), |
|
981 sizeof( TAiwMultipleContactAssignDataV1 ) ); |
|
982 |
|
983 // Multi assign does not support new contact |
|
984 // creation nor does it support contact editor, |
|
985 // so disable those |
|
986 TUint flags = dataPckg().Flags(); |
|
987 flags &= ~ECreateNewContact; |
|
988 flags |= EDoNotOpenEditor; |
|
989 dataPckg().SetFlags( flags ); |
|
990 |
|
991 delete iInstructionsPackage; |
|
992 iInstructionsPackage = NULL; |
|
993 iInstructionsPackage = dataPckg.AllocL(); |
|
994 break; |
|
995 } |
|
996 |
|
997 case EAiwContactAttributeAssignV1: |
|
998 { |
|
999 TAiwContactAttributeAssignDataV1Pckg dataPckg; |
|
1000 |
|
1001 // Reconstruct the instructions |
|
1002 dataPckg.Copy( iInstructionsPackage->Ptr(), |
|
1003 sizeof( TAiwContactAttributeAssignDataV1 ) ); |
|
1004 |
|
1005 // Attribute assign does not support new contact |
|
1006 // creation nor does it support contact editor, |
|
1007 // so disable those |
|
1008 TUint flags = dataPckg().Flags(); |
|
1009 flags &= ~ECreateNewContact; |
|
1010 flags |= EDoNotOpenEditor; |
|
1011 dataPckg().SetFlags( flags ); |
|
1012 |
|
1013 delete iInstructionsPackage; |
|
1014 iInstructionsPackage = NULL; |
|
1015 iInstructionsPackage = dataPckg.AllocL(); |
|
1016 break; |
|
1017 } |
|
1018 |
|
1019 default: |
|
1020 { |
|
1021 __ASSERT_DEBUG( EFalse, Panic( EDataTypeNotSupported ) ); |
|
1022 break; |
|
1023 } |
|
1024 } |
|
1025 |
|
1026 } |
|
1027 |
|
1028 // If client does not give instructions then default |
|
1029 // to multiple contact assign |
|
1030 if ( !iInstructionsPackage ) |
|
1031 { |
|
1032 TAiwMultipleContactAssignDataV1Pckg dataPckg; |
|
1033 iInstructionsPackage = dataPckg.AllocL(); |
|
1034 } |
|
1035 } |
|
1036 |
|
1037 // -------------------------------------------------------------------------- |
|
1038 // CPbk2AiwAssignProvider::ValidateMenuServiceL |
|
1039 // -------------------------------------------------------------------------- |
|
1040 // |
|
1041 void CPbk2AiwAssignProvider::ValidateMenuServiceL( const TInt& aCmdId ) |
|
1042 { |
|
1043 // Version check |
|
1044 TInt version = TAiwContactAssignDataBase:: |
|
1045 AssignDataTypeFromBuffer( *iInstructionsPackage ); |
|
1046 if ( version == EAiwContactAssignDataTypeNotDefined ) |
|
1047 { |
|
1048 User::Leave( KErrArgument ); |
|
1049 } |
|
1050 |
|
1051 switch ( aCmdId ) |
|
1052 { |
|
1053 case EPbk2AiwCmdAssign: |
|
1054 { |
|
1055 // Nothing to validate |
|
1056 break; |
|
1057 } |
|
1058 |
|
1059 case EPbk2AiwCmdDataSaveCreateNew: |
|
1060 { |
|
1061 // Create new supports only single contact assign |
|
1062 if ( version != EAiwSingleContactAssignV1 ) |
|
1063 { |
|
1064 User::Leave( KErrArgument ); |
|
1065 } |
|
1066 |
|
1067 TAiwSingleContactAssignDataV1Pckg dataPckg; |
|
1068 // Reconstruct the instructions |
|
1069 dataPckg.Copy( iInstructionsPackage->Ptr(), |
|
1070 sizeof( TAiwSingleContactAssignDataV1 ) ); |
|
1071 TUint flags = dataPckg().Flags(); |
|
1072 // Make sure the Create New Contact flag is up |
|
1073 flags |= ECreateNewContact; |
|
1074 dataPckg().SetFlags( flags ); |
|
1075 |
|
1076 delete iInstructionsPackage; |
|
1077 iInstructionsPackage = NULL; |
|
1078 iInstructionsPackage = dataPckg.AllocL(); |
|
1079 break; |
|
1080 } |
|
1081 |
|
1082 case EPbk2AiwCmdDataSaveAddToExisting: |
|
1083 { |
|
1084 // Update existing can be done to multiple contacts |
|
1085 // or to a single contact. We must take care that |
|
1086 // create new contact flag is down. |
|
1087 switch ( version ) |
|
1088 { |
|
1089 case EAiwMultipleContactAssignV1: |
|
1090 { |
|
1091 TAiwMultipleContactAssignDataV1Pckg dataPckg; |
|
1092 // Reconstruct the instructions |
|
1093 dataPckg.Copy( iInstructionsPackage->Ptr(), |
|
1094 sizeof( TAiwMultipleContactAssignDataV1 ) ); |
|
1095 TUint flags = dataPckg().Flags(); |
|
1096 // Make sure the Create New Contact flag is down |
|
1097 flags &= ~ECreateNewContact; |
|
1098 dataPckg().SetFlags( flags ); |
|
1099 |
|
1100 delete iInstructionsPackage; |
|
1101 iInstructionsPackage = NULL; |
|
1102 iInstructionsPackage = dataPckg.AllocL(); |
|
1103 break; |
|
1104 } |
|
1105 case EAiwSingleContactAssignV1: |
|
1106 { |
|
1107 TAiwSingleContactAssignDataV1Pckg dataPckg; |
|
1108 // Reconstruct the instructions |
|
1109 dataPckg.Copy( iInstructionsPackage->Ptr(), |
|
1110 sizeof( TAiwSingleContactAssignDataV1 ) ); |
|
1111 TUint flags = dataPckg().Flags(); |
|
1112 // Make sure the Create New Contact flag is down |
|
1113 flags &= ~ECreateNewContact; |
|
1114 dataPckg().SetFlags(flags); |
|
1115 |
|
1116 delete iInstructionsPackage; |
|
1117 iInstructionsPackage = NULL; |
|
1118 iInstructionsPackage = dataPckg.AllocL(); |
|
1119 break; |
|
1120 } |
|
1121 default: |
|
1122 { |
|
1123 __ASSERT_DEBUG( EFalse, Panic( EDataTypeNotSupported ) ); |
|
1124 break; |
|
1125 } |
|
1126 }; |
|
1127 |
|
1128 break; |
|
1129 } |
|
1130 |
|
1131 default: |
|
1132 { |
|
1133 // Service was used from client applications own menu |
|
1134 // or as a base service. Nothing to do. |
|
1135 break; |
|
1136 } |
|
1137 } |
|
1138 } |
|
1139 |
|
1140 // -------------------------------------------------------------------------- |
|
1141 // CPbk2AiwAssignProvider::ClientTitlePaneL |
|
1142 // -------------------------------------------------------------------------- |
|
1143 // |
|
1144 HBufC* CPbk2AiwAssignProvider::ClientTitlePaneL() |
|
1145 { |
|
1146 HBufC* result = NULL; |
|
1147 |
|
1148 CEikStatusPane* statusPane = |
|
1149 CEikonEnv::Static()->AppUiFactory()->StatusPane(); |
|
1150 |
|
1151 if ( statusPane && |
|
1152 statusPane->PaneCapabilities( |
|
1153 TUid::Uid( EEikStatusPaneUidTitle ) ).IsPresent() ) |
|
1154 { |
|
1155 CAknTitlePane* titlePane = static_cast<CAknTitlePane*>( statusPane-> |
|
1156 ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
1157 |
|
1158 if ( titlePane->Text() ) |
|
1159 { |
|
1160 result = titlePane->Text()->AllocL(); |
|
1161 } |
|
1162 } |
|
1163 |
|
1164 return result; |
|
1165 } |
|
1166 |
|
1167 // -------------------------------------------------------------------------- |
|
1168 // CPbk2AiwAssignProvider::ClientOrientation |
|
1169 // -------------------------------------------------------------------------- |
|
1170 // |
|
1171 HBufC* CPbk2AiwAssignProvider::ClientOrientation() const |
|
1172 { |
|
1173 HBufC* result = NULL; |
|
1174 |
|
1175 CAknViewAppUi* appUi = static_cast<CAknViewAppUi*> ( CEikonEnv::Static()->EikAppUi() ); |
|
1176 |
|
1177 if( appUi ) |
|
1178 { |
|
1179 TInt orientationType = appUi->Orientation(); |
|
1180 result = HBufC::New( sizeof(orientationType) ); |
|
1181 TPtr resultPtr = result->Des(); |
|
1182 resultPtr.Num( orientationType ); |
|
1183 } |
|
1184 return result; |
|
1185 } |
|
1186 |
|
1187 // -------------------------------------------------------------------------- |
|
1188 // CPbk2AiwAssignProvider::LaunchAttributeAssignL |
|
1189 // -------------------------------------------------------------------------- |
|
1190 // |
|
1191 inline void CPbk2AiwAssignProvider::LaunchAttributeAssignL |
|
1192 ( const CAiwGenericParamList& aInParamList, |
|
1193 const TGenericParamId aSemanticId ) |
|
1194 { |
|
1195 iAttributeData = |
|
1196 CreateAttributePackageL( aInParamList, aSemanticId ); |
|
1197 |
|
1198 // Check does the client want to assign attribute, |
|
1199 // or does it want to unassign instead |
|
1200 TAiwContactAttributeAssignDataV1Pckg data; |
|
1201 data.Copy( *iInstructionsPackage ); |
|
1202 TBool unassign = data().RemoveAttribute(); |
|
1203 |
|
1204 if ( !unassign ) |
|
1205 { |
|
1206 // Launch assign |
|
1207 iConnection->LaunchAttributeAssignL |
|
1208 ( iConfigurationPackage, iAttributeData, iInstructionsPackage ); |
|
1209 } |
|
1210 else |
|
1211 { |
|
1212 // Unassign service requires that contact links are also being sent |
|
1213 // to the server |
|
1214 if ( !FindSemanticId |
|
1215 ( aInParamList, EGenericParamContactLinkArray ) ) |
|
1216 { |
|
1217 User::Leave( KErrArgument ); |
|
1218 } |
|
1219 |
|
1220 // Launch unassign |
|
1221 iConnection->LaunchAttributeUnassignL |
|
1222 ( iConfigurationPackage, iAttributeData, iInstructionsPackage ); |
|
1223 } |
|
1224 } |
|
1225 |
|
1226 // -------------------------------------------------------------------------- |
|
1227 // CPbk2AiwAssignProvider::LaunchDataAssignL |
|
1228 // -------------------------------------------------------------------------- |
|
1229 // |
|
1230 inline void CPbk2AiwAssignProvider::LaunchDataAssignL |
|
1231 ( const CAiwGenericParamList& aInParamList, |
|
1232 const TGenericParamId aSemanticId ) |
|
1233 { |
|
1234 CreateDataPackageL( aInParamList, aSemanticId ); |
|
1235 |
|
1236 // Launch |
|
1237 iConnection->LaunchAssignL |
|
1238 ( iConfigurationPackage, iDataPackage, iInstructionsPackage ); |
|
1239 } |
|
1240 |
|
1241 // -------------------------------------------------------------------------- |
|
1242 // CPbk2AiwAssignProvider::PackImppParametersToBuffer |
|
1243 // -------------------------------------------------------------------------- |
|
1244 // |
|
1245 HBufC* CPbk2AiwAssignProvider::PackImppParametersToBufferL( |
|
1246 const CAiwGenericParamList& aInParamList) |
|
1247 { |
|
1248 _LIT(KSeparator, "\n"); |
|
1249 const TInt KParamsCount = 4; |
|
1250 TGenericParamId paramId[KParamsCount] = {EGenericParamXSpId, |
|
1251 EGenericParamFirstName, EGenericParamLastName, |
|
1252 EGenericParamNickname}; |
|
1253 TPtrC params[KParamsCount] = {TPtrC(), TPtrC(), TPtrC(), TPtrC()}; |
|
1254 HBufC* paramsBuf[KParamsCount] = {NULL, NULL, NULL, NULL}; |
|
1255 |
|
1256 TInt i = 0; |
|
1257 TInt separators = 0; |
|
1258 TInt length = 0; |
|
1259 // read all parameters |
|
1260 for (; i < KParamsCount; i++) |
|
1261 { |
|
1262 TInt paramIndex = 0; |
|
1263 const TAiwGenericParam* paramData = |
|
1264 aInParamList.FindFirst(paramIndex, paramId[i]); |
|
1265 if (paramData && paramData->Value().AsData().Ptr()) |
|
1266 { |
|
1267 // Data was given as 8-bit, transform it into 16-bit |
|
1268 TPtrC8 ptr = paramData->Value().AsData(); |
|
1269 paramsBuf[i] = HBufC::NewLC(ptr.Size()); |
|
1270 paramsBuf[i]->Des().Copy(ptr); |
|
1271 params[i].Set(*paramsBuf[i]); |
|
1272 separators = i; |
|
1273 } |
|
1274 else if ( paramData && paramData->Value().AsDes().Ptr() ) |
|
1275 { |
|
1276 params[i].Set(paramData->Value().AsDes()); |
|
1277 separators = i; |
|
1278 } |
|
1279 length += params[i].Length(); |
|
1280 } |
|
1281 |
|
1282 HBufC* result = HBufC::NewL(length+separators); |
|
1283 TPtr ptr = result->Des(); |
|
1284 // now separators will be used to count fields |
|
1285 // but fields is one more than separators |
|
1286 separators++; |
|
1287 // create parameter string for server |
|
1288 for (i = 0; i < separators; i++) |
|
1289 { |
|
1290 if (i) |
|
1291 { |
|
1292 ptr.Append(KSeparator); |
|
1293 } |
|
1294 ptr.Append(params[i]); |
|
1295 } |
|
1296 |
|
1297 // clean cleanup stack |
|
1298 for (i = KParamsCount-1; i >= 0; i--) |
|
1299 { |
|
1300 if (paramsBuf[i]) |
|
1301 { |
|
1302 CleanupStack::PopAndDestroy(paramsBuf[i]); |
|
1303 } |
|
1304 } |
|
1305 |
|
1306 return result; |
|
1307 } |
|
1308 |
|
1309 // End of File |