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