196 |
196 |
197 if ( action == IHsDataObserver::EDeactivate ) |
197 if ( action == IHsDataObserver::EDeactivate ) |
198 { |
198 { |
199 // remove widget data when widget removed from screen |
199 // remove widget data when widget removed from screen |
200 CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC(); |
200 CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC(); |
201 InsertWidgetDataIdentifiersL( aWidget, cpdatamap, KAll ); |
201 InsertWidgetDataIdentifiersL( aWidget, cpdatamap ); |
202 // removal may fail if the client has already removed the data |
202 // removal may fail if the client has already removed the data |
203 TRAP_IGNORE( RemoveFromCpsL( cpdatamap, KCpData ) ); |
203 TRAP_IGNORE( RemoveFromCpsL( cpdatamap, KCpData ) ); |
204 mWidgetContentIds.erase( aWidget.getIdentifier() ); |
204 mWidgetContentIds.erase( aWidget.getIdentifier() ); |
205 CleanupStack::PopAndDestroy( cpdatamap ); |
205 CleanupStack::PopAndDestroy( cpdatamap ); |
206 } |
206 } |
409 // --------------------------------------------------------------------------- |
409 // --------------------------------------------------------------------------- |
410 // |
410 // |
411 // --------------------------------------------------------------------------- |
411 // --------------------------------------------------------------------------- |
412 // |
412 // |
413 void HsWidgetPublisherImpl::PublishWidgetDataL( HsWidget& aWidget ) |
413 void HsWidgetPublisherImpl::PublishWidgetDataL( HsWidget& aWidget ) |
414 { |
414 { |
415 CLiwGenericParamList* inParam = &(mServiceHandler->InParamListL()); |
415 CLiwGenericParamList* inParam = &(mServiceHandler->InParamListL()); |
416 CLiwGenericParamList* outParam = &(mServiceHandler->OutParamListL()); |
416 CLiwGenericParamList* outParam = &(mServiceHandler->OutParamListL()); |
417 TLiwGenericParam type(KType, TLiwVariant(KCpData)); |
417 |
418 |
418 TLiwGenericParam type(KType, TLiwVariant(KCpData)); |
419 int count = aWidget.itemsCount(); |
419 inParam->AppendL(type); |
420 for( int i = 0; i < count; i++ ) |
420 |
421 { |
421 CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC(); |
422 inParam->AppendL(type); |
422 InsertWidgetDataIdentifiersL( aWidget, cpdatamap ); |
423 CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC(); |
423 |
424 |
424 CLiwDefaultMap* datamap = CLiwDefaultMap::NewLC(); |
425 HsWidgetItem* const widgetItem = aWidget.getWidgetItem( i ); |
425 InsertWidgetItemsL( aWidget, datamap ); |
426 |
426 cpdatamap->InsertL( KDataMap, TLiwVariant( datamap ) ); |
427 // insert widget data identifiers |
427 InsertWidgetACLL( cpdatamap ); |
428 HBufC* itemName = StdStringToUnicodeLC( widgetItem->getItemName()); |
428 |
429 InsertWidgetDataIdentifiersL( aWidget, cpdatamap, *itemName ); |
429 int count = aWidget.itemsCount(); |
430 CleanupStack::PopAndDestroy( itemName ); |
430 if( count > 0 ) |
431 |
431 { |
432 // insert widget item |
432 CLiwDefaultMap* triggermap = CLiwDefaultMap::NewLC(); |
433 CLiwDefaultMap* datamap = CLiwDefaultMap::NewLC(); |
433 InsertItemsTriggersL( aWidget, triggermap ); |
434 InsertWidgetItemL( *widgetItem, datamap ); |
434 cpdatamap->InsertL( KActionMap, TLiwVariant( triggermap ) ); |
435 cpdatamap->InsertL( KDataMap, TLiwVariant( datamap ) ); |
435 CleanupStack::PopAndDestroy( triggermap ); |
436 |
436 } |
437 // insert widget access control list |
|
438 InsertWidgetACLL( cpdatamap ); |
|
439 |
|
440 // insert item triggers |
|
441 CLiwDefaultMap* triggermap = CLiwDefaultMap::NewLC(); |
|
442 InsertItemTriggerL( *widgetItem, triggermap ); |
|
443 cpdatamap->InsertL( KActionMap, TLiwVariant( triggermap ) ); |
|
444 CleanupStack::PopAndDestroy( triggermap ); |
|
445 |
437 |
446 // add to CPS |
438 // add to CPS |
447 TLiwGenericParam item( KItem, TLiwVariant( cpdatamap )); |
439 TLiwGenericParam item( KItem, TLiwVariant( cpdatamap )); |
448 inParam->AppendL( item ); |
440 inParam->AppendL( item ); |
449 mServiceInterface->ExecuteCmdL( KAdd, |
441 mServiceInterface->ExecuteCmdL( KAdd, |
450 *inParam, *outParam); |
442 *inParam, *outParam); |
451 TInt ret= ObtainErrorCode( *outParam ); |
443 TInt ret= ObtainErrorCode( *outParam ); |
452 |
444 |
453 CleanupStack::PopAndDestroy( datamap ); |
445 CleanupStack::PopAndDestroy( datamap ); |
454 CleanupStack::PopAndDestroy( cpdatamap ); |
446 CleanupStack::PopAndDestroy( cpdatamap ); |
455 |
447 |
456 item.Reset(); |
448 item.Reset(); |
457 outParam->Reset(); |
449 type.Reset(); |
458 inParam->Reset(); |
450 outParam->Reset(); |
459 User::LeaveIfError( ret ); |
451 inParam->Reset(); |
460 } |
452 User::LeaveIfError( ret ); |
461 type.Reset(); |
|
462 } |
453 } |
463 |
454 |
464 // --------------------------------------------------------------------------- |
455 // --------------------------------------------------------------------------- |
465 // |
456 // |
466 // --------------------------------------------------------------------------- |
457 // --------------------------------------------------------------------------- |
781 // --------------------------------------------------------------------------- |
772 // --------------------------------------------------------------------------- |
782 // |
773 // |
783 // --------------------------------------------------------------------------- |
774 // --------------------------------------------------------------------------- |
784 // |
775 // |
785 void HsWidgetPublisherImpl::InsertWidgetDataIdentifiersL( HsWidget& aWidget, |
776 void HsWidgetPublisherImpl::InsertWidgetDataIdentifiersL( HsWidget& aWidget, |
786 CLiwDefaultMap* aDataMap, const TDesC& aContentType ) |
777 CLiwDefaultMap* aDataMap ) |
787 { |
778 { |
788 WidgetContentIdMapType::const_iterator contentIdIter = |
779 WidgetContentIdMapType::const_iterator contentIdIter = |
789 mWidgetContentIds.find( aWidget.getIdentifier() ); |
780 mWidgetContentIds.find( aWidget.getIdentifier() ); |
790 if ( contentIdIter == mWidgetContentIds.end() ) |
781 if ( contentIdIter == mWidgetContentIds.end() ) |
791 { |
782 { |
795 contentIdIter->second.c_str() ); |
786 contentIdIter->second.c_str() ); |
796 |
787 |
797 HBufC* publisherName = StdStringToUnicodeLC( GetPublisherNameL( aWidget ) ); |
788 HBufC* publisherName = StdStringToUnicodeLC( GetPublisherNameL( aWidget ) ); |
798 |
789 |
799 aDataMap->InsertL( KPublisherId, TLiwVariant( *publisherName ) ); |
790 aDataMap->InsertL( KPublisherId, TLiwVariant( *publisherName ) ); |
800 aDataMap->InsertL( KContentType, TLiwVariant( aContentType ) ); |
791 aDataMap->InsertL( KContentType, TLiwVariant( KAll ) ); |
801 aDataMap->InsertL( KContentId, TLiwVariant( contentId ) ); |
792 aDataMap->InsertL( KContentId, TLiwVariant( contentId ) ); |
802 |
793 |
803 CleanupStack::PopAndDestroy( publisherName ); |
794 CleanupStack::PopAndDestroy( publisherName ); |
804 } |
795 } |
805 |
796 |
843 |
834 |
844 // --------------------------------------------------------------------------- |
835 // --------------------------------------------------------------------------- |
845 // |
836 // |
846 // --------------------------------------------------------------------------- |
837 // --------------------------------------------------------------------------- |
847 // |
838 // |
848 void HsWidgetPublisherImpl::InsertWidgetItemL ( HsWidgetItem& aWidgetItem, |
839 void HsWidgetPublisherImpl::InsertWidgetItemsL ( HsWidget& aWidget, |
849 CLiwDefaultMap* aDataMap ) |
840 CLiwDefaultMap* aDataMap ) |
850 { |
841 { |
851 TPtrC8 itemName = ((TUint8*)aWidgetItem.getItemName().c_str()); |
842 int count = aWidget.itemsCount(); |
852 if( aWidgetItem.isStringValue() ) |
843 for (int index = 0; index < count; index++) |
853 { |
844 { |
854 TPtrC8 itemValue = ((TUint8*)aWidgetItem.getItemValue().c_str()); |
845 HsWidgetItem* const item = aWidget.getWidgetItem( index ); |
855 HBufC* value = HBufC::NewLC( KUnicodeSize * itemValue.Length() ); |
846 |
856 TPtr dest( value->Des() ); |
847 TPtrC8 itemName = ((TUint8*)item->getItemName().c_str()); |
857 CnvUtfConverter::ConvertToUnicodeFromUtf8( dest, itemValue ); |
848 if( item->isStringValue() ) |
858 |
849 { |
859 aDataMap->InsertL( itemName, TLiwVariant(*value )); |
850 TPtrC8 itemValue = ((TUint8*)item->getItemValue().c_str()); |
860 CleanupStack::PopAndDestroy(value); |
851 HBufC* value = HBufC::NewLC( KUnicodeSize * itemValue.Length() ); |
861 } |
852 TPtr dest( value->Des() ); |
862 else |
853 CnvUtfConverter::ConvertToUnicodeFromUtf8( dest, itemValue ); |
863 { |
854 |
864 int itemValue = aWidgetItem.getItemValueInt(); |
855 aDataMap->InsertL( itemName, TLiwVariant(*value )); |
865 aDataMap->InsertL( itemName, TLiwVariant( TInt32( itemValue ) )); |
856 CleanupStack::PopAndDestroy(value); |
866 } |
857 } |
|
858 else |
|
859 { |
|
860 int itemValue = item->getItemValueInt(); |
|
861 aDataMap->InsertL( itemName, TLiwVariant( TInt32( itemValue ) )); |
|
862 } |
|
863 } |
867 } |
864 } |
868 |
865 |
869 // --------------------------------------------------------------------------- |
866 // --------------------------------------------------------------------------- |
870 // |
867 // |
871 // --------------------------------------------------------------------------- |
868 // --------------------------------------------------------------------------- |
939 |
936 |
940 // --------------------------------------------------------------------------- |
937 // --------------------------------------------------------------------------- |
941 // |
938 // |
942 // --------------------------------------------------------------------------- |
939 // --------------------------------------------------------------------------- |
943 // |
940 // |
944 void HsWidgetPublisherImpl::InsertItemTriggerL( HsWidgetItem& aWidgetItem, |
941 void HsWidgetPublisherImpl::InsertItemsTriggersL( HsWidget& aWidget, |
945 CLiwDefaultMap* aTriggerMap ) |
942 CLiwDefaultMap* aTriggerMap ) |
946 { |
943 { |
|
944 int count = aWidget.itemsCount(); |
947 CLiwDefaultMap* activateAction = CLiwDefaultMap::NewLC(); |
945 CLiwDefaultMap* activateAction = CLiwDefaultMap::NewLC(); |
948 activateAction->InsertL( KPluginId, TLiwVariant( KCASpaAppLauncherPlugin ) ); |
946 activateAction->InsertL( KPluginId, TLiwVariant( KCASpaAppLauncherPlugin ) ); |
949 |
947 |
950 CLiwDefaultMap* activate = CLiwDefaultMap::NewLC(); |
948 CLiwDefaultMap* activate = CLiwDefaultMap::NewLC(); |
951 activate->InsertL( KType, TLiwVariant( KActionValueLaunchApplication ) ); |
949 activate->InsertL( KType, TLiwVariant( KActionValueLaunchApplication ) ); |
952 activate->InsertL( KLaunchMethod, TLiwVariant( KLaunchMethodValueCmdLine ) ); |
950 activate->InsertL( KLaunchMethod, TLiwVariant( KLaunchMethodValueCmdLine ) ); |
953 activate->InsertL( KApplicationUid, TLiwVariant( iWidgetUid ) ); |
951 activate->InsertL( KApplicationUid, TLiwVariant( iWidgetUid ) ); |
954 activate->InsertL( KApaCommand, TLiwVariant( KApaCommandBackground ) ); |
952 activate->InsertL( KApaCommand, TLiwVariant( KApaCommandBackground ) ); |
955 |
953 |
956 activateAction->InsertL( KData, TLiwVariant( activate ) ); |
954 activateAction->InsertL( KData, TLiwVariant( activate ) ); |
957 |
955 |
958 TPtrC8 itemName = ((TUint8*)aWidgetItem.getItemName().c_str()); |
956 for (int index = 0; index < count; index++) |
959 aTriggerMap->InsertL( itemName, TLiwVariant( activateAction )); |
957 { |
960 |
958 HsWidgetItem* const item = aWidget.getWidgetItem( index ); |
|
959 TPtrC8 itemName = ((TUint8*)item->getItemName().c_str()); |
|
960 aTriggerMap->InsertL( itemName, TLiwVariant( activateAction )); |
|
961 } |
961 CleanupStack::PopAndDestroy( activate ); |
962 CleanupStack::PopAndDestroy( activate ); |
962 CleanupStack::PopAndDestroy( activateAction ); |
963 CleanupStack::PopAndDestroy( activateAction ); |
963 } |
964 } |
964 |
965 |
965 // --------------------------------------------------------------------------- |
966 // --------------------------------------------------------------------------- |