101 // --------------------------------------------------------------------------- |
102 // --------------------------------------------------------------------------- |
102 // |
103 // |
103 void CSapiData::ConstructL(CSapiDataPlugin* aPlugin) |
104 void CSapiData::ConstructL(CSapiDataPlugin* aPlugin) |
104 { |
105 { |
105 iPlugin = aPlugin; |
106 iPlugin = aPlugin; |
106 iCommandName = NULL; |
|
107 iContentId = NULL; |
|
108 iContentType = NULL; |
|
109 iUpdateNeeded = EFalse; |
107 iUpdateNeeded = EFalse; |
|
108 iGetMenuItems = ETrue; |
110 } |
109 } |
111 |
110 |
112 // --------------------------------------------------------------------------- |
111 // --------------------------------------------------------------------------- |
113 // Destructor |
112 // Destructor |
114 // Deletes all data created to heap |
113 // Deletes all data created to heap |
115 // --------------------------------------------------------------------------- |
114 // --------------------------------------------------------------------------- |
116 // |
115 // |
117 CSapiData::~CSapiData() |
116 CSapiData::~CSapiData() |
118 { |
117 { |
119 delete iCommandName; |
|
120 delete iPublisher; |
118 delete iPublisher; |
121 delete iContentType; |
|
122 delete iContentId; |
119 delete iContentId; |
123 delete iStartupReason; |
120 delete iStartupReason; |
124 |
121 |
125 if(iPubObserver) |
122 if(iPubObserver) |
126 { |
123 { |
127 TRAP_IGNORE(iPubObserver->ReleaseL() ); |
|
128 delete iPubObserver; |
124 delete iPubObserver; |
129 iPubObserver = NULL; |
125 iPubObserver = NULL; |
130 } |
126 } |
131 if(iContentObserver) |
127 if(iContentObserver) |
132 { |
128 { |
133 TRAP_IGNORE(iContentObserver->ReleaseL() ); |
|
134 delete iContentObserver; |
129 delete iContentObserver; |
135 iContentObserver = NULL; |
130 iContentObserver = NULL; |
136 } |
131 } |
137 if( iInterface ) |
|
138 { |
|
139 iInterface->Close(); |
|
140 iInterface = NULL; |
|
141 } |
|
142 if( iServiceHandler ) |
|
143 { |
|
144 iServiceHandler->Reset(); |
|
145 delete iServiceHandler; |
|
146 iServiceHandler = NULL; |
|
147 } |
|
148 iMenuItems.ResetAndDestroy(); |
132 iMenuItems.ResetAndDestroy(); |
149 iMenuTriggers.ResetAndDestroy(); |
133 iMenuTriggers.ResetAndDestroy(); |
150 iItemList.ResetAndDestroy(); |
134 iItemList.ResetAndDestroy(); |
151 // not owned |
135 // not owned |
152 iPlugin = NULL; |
136 iPlugin = NULL; |
|
137 iInterface = NULL; |
|
138 iServiceHandler = NULL; |
|
139 iCpsExecute = NULL; |
|
140 |
153 } |
141 } |
154 |
142 |
155 // --------------------------------------------------------------------------- |
143 // --------------------------------------------------------------------------- |
156 // ConfigureL |
144 // ConfigureL |
157 // --------------------------------------------------------------------------- |
145 // --------------------------------------------------------------------------- |
158 // |
146 // |
159 void CSapiData::ConfigureL(RAiSettingsItemArray& aConfigurations ) |
147 void CSapiData::ConfigureL(RAiSettingsItemArray& aConfigurations ) |
160 { |
148 { |
161 HBufC8* serviceName = NULL; |
|
162 HBufC8* interfaceName = NULL; |
|
163 |
|
164 TInt count = aConfigurations.Count(); |
149 TInt count = aConfigurations.Count(); |
165 |
|
166 for(TInt i = 0;i<count;i++) |
150 for(TInt i = 0;i<count;i++) |
167 { |
151 { |
168 MAiPluginConfigurationItem& confItem = ( aConfigurations[i] )->AiPluginConfigurationItem(); |
152 MAiPluginConfigurationItem& confItem = ( aConfigurations[i] )->AiPluginConfigurationItem(); |
169 // if owner is plugin then it (key,value) is for plugin configurations items |
|
170 if(confItem.Owner() == KPlugin()) |
153 if(confItem.Owner() == KPlugin()) |
171 { |
154 { |
172 if(confItem.Name() == KService()) |
155 if( confItem.Name() == KPublisher16() ) |
173 { |
|
174 serviceName = CnvUtfConverter::ConvertFromUnicodeToUtf8L(confItem.Value()); |
|
175 } |
|
176 else if( confItem.Name() == KInterface() ) |
|
177 { |
|
178 interfaceName = CnvUtfConverter::ConvertFromUnicodeToUtf8L(confItem.Value()); |
|
179 } |
|
180 else if( confItem.Name() == KCommand() ) |
|
181 { |
|
182 iCommandName = CnvUtfConverter::ConvertFromUnicodeToUtf8L(confItem.Value()); |
|
183 } |
|
184 else if( confItem.Name() == KPublisher16() ) |
|
185 { |
156 { |
186 iPublisher = confItem.Value().AllocL(); |
157 iPublisher = confItem.Value().AllocL(); |
187 } |
158 } |
188 } |
159 } |
189 else if ( confItem.Name() == KContentType16() ) |
160 else if ( confItem.Name() == KContentType16() ) |
199 iItemList.AppendL( conItem ); |
170 iItemList.AppendL( conItem ); |
200 |
171 |
201 CleanupStack::PopAndDestroy(objectId); |
172 CleanupStack::PopAndDestroy(objectId); |
202 } |
173 } |
203 } |
174 } |
204 |
|
205 iItemCount = iItemList.Count(); |
175 iItemCount = iItemList.Count(); |
206 |
176 if( iPublisher->Des().Length() == 0 ) |
207 if( !serviceName || !interfaceName || !iCommandName |
|
208 || !iContentId || !iPublisher || !iItemCount ) |
|
209 { |
177 { |
210 // No service to offer without plugin configurations |
178 // No service to offer without plugin configurations |
211 User::Leave( KErrNotSupported ); |
179 User::Leave( KErrNotSupported ); |
212 } |
180 } |
213 iServiceHandler = CLiwServiceHandler::NewL(); |
|
214 |
|
215 // for convenience keep pointers to Service Handler param lists |
|
216 CLiwGenericParamList* inParamList = &iServiceHandler->InParamListL(); |
|
217 CLiwGenericParamList* outParamList = &iServiceHandler->OutParamListL(); |
|
218 |
|
219 CLiwCriteriaItem* criteriaItem = CLiwCriteriaItem::NewLC( KLiwCmdAsStr, *interfaceName , *serviceName ); |
|
220 criteriaItem->SetServiceClass( TUid::Uid( KLiwClassBase ) ); |
|
221 // Interface name |
|
222 RCriteriaArray criteriaArray; |
|
223 criteriaArray.AppendL( criteriaItem ); |
|
224 // attach Liw criteria |
|
225 iServiceHandler->AttachL( criteriaArray ); |
|
226 iServiceHandler->ExecuteServiceCmdL( *criteriaItem, *inParamList, *outParamList ); |
|
227 |
|
228 CleanupStack::PopAndDestroy(criteriaItem); |
|
229 criteriaArray.Reset(); |
|
230 |
|
231 // extract CPS interface from output params |
|
232 TInt pos( 0 ); |
|
233 outParamList->FindFirst( pos, *interfaceName ); |
|
234 if( pos != KErrNotFound ) |
|
235 { |
|
236 //iInterface is MLiwInterface* |
|
237 iInterface = (*outParamList)[pos].Value().AsInterface(); |
|
238 User::LeaveIfNull( iInterface ); |
|
239 } |
|
240 else |
|
241 { |
|
242 User::Leave( KErrNotFound ); |
|
243 } |
|
244 inParamList->Reset(); |
|
245 outParamList->Reset(); |
|
246 delete interfaceName; |
|
247 delete serviceName; |
|
248 |
|
249 //Gets the menu items from the publisher registry |
|
250 GetMenuItemsL(); |
|
251 |
|
252 iContentObserver = CSapiDataObserver::NewL( iInterface, this ); |
181 iContentObserver = CSapiDataObserver::NewL( iInterface, this ); |
253 iPubObserver = CSapiDataObserver::NewL( iInterface, this ); |
182 iPubObserver = CSapiDataObserver::NewL( iInterface, this ); |
254 } |
183 } |
255 |
184 |
256 // --------------------------------------------------------------------------- |
185 // --------------------------------------------------------------------------- |
568 // --------------------------------------------------------------------------- |
504 // --------------------------------------------------------------------------- |
569 // |
505 // |
570 void CSapiData::ExecuteCommandL(const TDesC& aRegistry, CLiwDefaultMap* aInFilter, |
506 void CSapiData::ExecuteCommandL(const TDesC& aRegistry, CLiwDefaultMap* aInFilter, |
571 CLiwGenericParamList* aOutParamList) |
507 CLiwGenericParamList* aOutParamList) |
572 { |
508 { |
573 CLiwGenericParamList* inParamList = &iServiceHandler->InParamListL(); |
509 if( iInterface == NULL ) |
574 |
510 { |
575 TLiwGenericParam type( KType, TLiwVariant( aRegistry ) ); |
511 User::Leave( KErrNotSupported ); |
576 inParamList->AppendL( type ); |
512 } |
577 |
513 CLiwGenericParamList* inParamList = &iServiceHandler->InParamListL(); |
578 //append filter to input param |
514 |
579 TLiwGenericParam item( KFilter, TLiwVariant( aInFilter )); |
515 TLiwGenericParam type( KType, TLiwVariant( aRegistry ) ); |
580 inParamList->AppendL( item ); |
516 inParamList->AppendL( type ); |
581 |
517 |
582 // execute service.It is assumed that iInterface is already initiated |
518 //append filter to input param |
583 if(iInterface) |
519 TLiwGenericParam item( KFilter, TLiwVariant( aInFilter )); |
584 { |
520 inParamList->AppendL( item ); |
585 iInterface->ExecuteCmdL( *iCommandName, *inParamList, *aOutParamList); |
521 |
586 } |
522 // execute service.It is assumed that iInterface is already initiated |
587 else |
523 iInterface->ExecuteCmdL( KGetList, *inParamList, *aOutParamList); |
588 { |
524 type.Reset(); |
589 User::Leave( KErrNotSupported ); |
525 item.Reset(); |
590 } |
526 inParamList->Reset(); |
591 type.Reset(); |
|
592 item.Reset(); |
|
593 inParamList->Reset(); |
|
594 } |
527 } |
595 |
528 |
596 // --------------------------------------------------------------------------- |
529 // --------------------------------------------------------------------------- |
597 // ExecuteActionL |
530 // ExecuteActionL |
598 // --------------------------------------------------------------------------- |
531 // --------------------------------------------------------------------------- |
599 // |
532 // |
600 void CSapiData::ExecuteActionL(const TDesC& aObjectId, const TDesC& aTrigger ) |
533 void CSapiData::ExecuteActionL(const TDesC& aObjectId, const TDesC& aTrigger ) |
601 { |
534 { |
|
535 if( iInterface == NULL ) |
|
536 { |
|
537 User::Leave( KErrNotSupported ); |
|
538 } |
602 HBufC8* triggerName = HBufC8::NewLC( KSAPIContentNameMaxLength ); |
539 HBufC8* triggerName = HBufC8::NewLC( KSAPIContentNameMaxLength ); |
603 |
540 |
604 CLiwGenericParamList* inParamList = &iServiceHandler->InParamListL(); |
541 CLiwGenericParamList* inParamList = &iServiceHandler->InParamListL(); |
605 CLiwGenericParamList* outParamList = &iServiceHandler->OutParamListL(); |
542 CLiwGenericParamList* outParamList = &iServiceHandler->OutParamListL(); |
606 CLiwDefaultMap* filter = NULL; |
543 CLiwDefaultMap* filter = NULL; |
719 { |
656 { |
720 return iPlugin->IsActive(); |
657 return iPlugin->IsActive(); |
721 } |
658 } |
722 |
659 |
723 // --------------------------------------------------------------------------- |
660 // --------------------------------------------------------------------------- |
724 // PublisherStatusL |
661 // ChangePublisherStatusL |
725 // --------------------------------------------------------------------------- |
662 // --------------------------------------------------------------------------- |
726 // |
663 // |
727 void CSapiData::ChangePublisherStatusL(const TDesC& aStatus) |
664 void CSapiData::ChangePublisherStatusL(const TDesC8& aStatus) |
728 { |
665 { |
|
666 if( iCpsExecute == NULL ) |
|
667 { |
|
668 User::Leave( KErrNotSupported ); |
|
669 } |
|
670 |
729 if ( aStatus == KResume && iUpdateNeeded ) |
671 if ( aStatus == KResume && iUpdateNeeded ) |
730 { |
672 { |
731 iPlugin->PublishL(); |
673 iPlugin->PublishL(); |
732 iUpdateNeeded = EFalse; |
674 iUpdateNeeded = EFalse; |
733 } |
675 } |
|
676 CLiwDefaultMap* filter = CreateFilterLC( KWidget() ); |
|
677 // Add execute command triggers. Idle framework will execute |
|
678 iCpsExecute->AddCommand( *iContentId, KPubData, filter, aStatus ); |
|
679 CleanupStack::PopAndDestroy( filter ); |
|
680 |
|
681 } |
|
682 |
|
683 // --------------------------------------------------------------------------- |
|
684 // ChangePublisherStatusL |
|
685 // --------------------------------------------------------------------------- |
|
686 // |
|
687 void CSapiData::ChangePublisherStatusL(CLiwDefaultList* aActionsList) |
|
688 { |
|
689 if( iInterface == NULL ) |
|
690 { |
|
691 User::Leave( KErrNotSupported ); |
|
692 } |
734 |
693 |
735 CLiwGenericParamList* inParamList = &iServiceHandler->InParamListL(); |
694 CLiwGenericParamList* inParamList = &iServiceHandler->InParamListL(); |
736 CLiwGenericParamList* outParamList = &iServiceHandler->OutParamListL(); |
695 CLiwGenericParamList* outParamList = &iServiceHandler->OutParamListL(); |
737 HBufC8* triggerName = CnvUtfConverter::ConvertFromUnicodeToUtf8L(aStatus); |
696 |
738 CleanupStack::PushL( triggerName ); |
|
739 |
|
740 TLiwGenericParam type( KType, TLiwVariant( KPubData ) ); |
697 TLiwGenericParam type( KType, TLiwVariant( KPubData ) ); |
741 inParamList->AppendL( type ); |
698 inParamList->AppendL( type ); |
742 |
699 |
743 CLiwDefaultMap* filter = CreateFilterLC( KWidget() ); |
700 CLiwDefaultMap* filter = CreateFilterLC( KWidget() ); |
744 filter->InsertL(KActionTrigger, TLiwVariant(triggerName->Des()) ); |
701 // add list of action triggers to execute |
745 |
702 filter->InsertL(KActionTrigger, TLiwVariant(aActionsList) ); |
|
703 |
746 TLiwGenericParam item( KFilter, TLiwVariant( filter )); |
704 TLiwGenericParam item( KFilter, TLiwVariant( filter )); |
747 inParamList->AppendL( item ); |
705 inParamList->AppendL( item ); |
748 |
706 |
|
707 iInterface->ExecuteCmdL( KExecuteAction, *inParamList, *outParamList); |
|
708 CleanupStack::PopAndDestroy( filter ); |
|
709 outParamList->Reset(); |
|
710 inParamList->Reset(); |
|
711 |
|
712 } |
|
713 |
|
714 // --------------------------------------------------------------------------- |
|
715 // TriggerActiveL |
|
716 // --------------------------------------------------------------------------- |
|
717 // |
|
718 void CSapiData::TriggerActiveL() |
|
719 { |
749 if(iInterface) |
720 if(iInterface) |
750 { |
721 { |
751 iInterface->ExecuteCmdL( KExecuteAction, *inParamList, *outParamList); |
722 CLiwGenericParamList* inParamList = &iServiceHandler->InParamListL(); |
752 } |
723 CLiwGenericParamList* outParamList = &iServiceHandler->OutParamListL(); |
753 else |
724 |
754 { |
725 TLiwGenericParam type( KType, TLiwVariant( KPubData ) ); |
755 User::Leave( KErrNotSupported ); |
726 inParamList->AppendL( type ); |
756 } |
727 |
757 |
728 CLiwDefaultMap* filter = CreateFilterLC( KAll(), KAll() ); |
758 CleanupStack::PopAndDestroy( filter ); |
729 filter->InsertL(KActionTrigger, TLiwVariant( KActive() )); |
759 CleanupStack::PopAndDestroy( triggerName ); |
730 |
760 inParamList->Reset(); |
731 TLiwGenericParam item( KFilter, TLiwVariant( filter )); |
761 outParamList->Reset(); |
732 inParamList->AppendL( item ); |
762 } |
733 iInterface->ExecuteCmdL( KExecuteAction, *inParamList, *outParamList, KDisableNotification ); |
763 |
734 |
764 // --------------------------------------------------------------------------- |
735 CleanupStack::PopAndDestroy( filter ); |
765 // TriggerActiveL |
736 inParamList->Reset(); |
766 // --------------------------------------------------------------------------- |
737 outParamList->Reset(); |
767 // |
|
768 void CSapiData::TriggerActiveL() |
|
769 { |
|
770 |
|
771 CLiwGenericParamList* inParamList = &iServiceHandler->InParamListL(); |
|
772 CLiwGenericParamList* outParamList = &iServiceHandler->OutParamListL(); |
|
773 |
|
774 TLiwGenericParam type( KType, TLiwVariant( KPubData ) ); |
|
775 inParamList->AppendL( type ); |
|
776 |
|
777 CLiwDefaultMap* filter = CreateFilterLC( KAll(), KAll() ); |
|
778 filter->InsertL(KActionTrigger, TLiwVariant( KActive() )); |
|
779 |
|
780 TLiwGenericParam item( KFilter, TLiwVariant( filter )); |
|
781 inParamList->AppendL( item ); |
|
782 if(iInterface) |
|
783 { |
|
784 iInterface->ExecuteCmdL( KExecuteAction, *inParamList, *outParamList, KDisableNotification ); |
|
785 } |
738 } |
786 else |
739 else |
787 { |
740 { |
788 User::Leave( KErrNotSupported ); |
741 User::Leave( KErrNotSupported ); |
789 } |
742 } |
790 CleanupStack::PopAndDestroy( filter ); |
|
791 inParamList->Reset(); |
|
792 outParamList->Reset(); |
|
793 } |
743 } |
794 // --------------------------------------------------------------------------- |
744 // --------------------------------------------------------------------------- |
795 // UpdatePublisherStatusL |
745 // UpdatePublisherStatusL |
796 // --------------------------------------------------------------------------- |
746 // --------------------------------------------------------------------------- |
797 // |
747 // |
798 void CSapiData::UpdatePublisherStatusL( TDesC& aPublisher ) |
748 void CSapiData::UpdatePublisherStatusL( TDesC& aPublisher ) |
799 { |
749 { |
800 if ( aPublisher == iPublisher ) |
750 if ( aPublisher == iPublisher ) |
801 { |
751 { |
802 // Resend the plugin status to publisher |
752 // Resend the plugin status to publisher |
803 ChangePublisherStatusL( KActive ); |
753 CLiwDefaultList* actionsToLaunch = CLiwDefaultList::NewLC(); |
|
754 actionsToLaunch->AppendL( TLiwVariant( KActive )); |
804 if( iStartupReason->Length() != 0 ) |
755 if( iStartupReason->Length() != 0 ) |
805 { |
756 { |
806 ChangePublisherStatusL( *iStartupReason ); |
757 actionsToLaunch->AppendL( TLiwVariant( *iStartupReason )); |
807 } |
758 } |
808 |
|
809 if ( iPlugin->IsActive() ) |
759 if ( iPlugin->IsActive() ) |
810 { |
760 { |
811 ChangePublisherStatusL( KResume ); |
761 actionsToLaunch->AppendL( TLiwVariant( KResume )); |
812 } |
762 } |
813 else |
763 else |
814 { |
764 { |
815 ChangePublisherStatusL( KSuspend ); |
765 actionsToLaunch->AppendL(TLiwVariant( KSuspend )); |
816 } |
766 } |
817 // forward the network status if it uses. |
767 // forward the network status if it uses. |
818 if ( iPlugin->NetworkStatus() == CSapiDataPlugin::EOnline ) |
768 if ( iPlugin->NetworkStatus() == CSapiDataPlugin::EOnline ) |
819 { |
769 { |
820 ChangePublisherStatusL( KOnLine ); |
770 actionsToLaunch->AppendL(TLiwVariant( KOnLine )); |
821 } |
771 } |
822 else if ( iPlugin->NetworkStatus() == CSapiDataPlugin::EOffline ) |
772 else if ( iPlugin->NetworkStatus() == CSapiDataPlugin::EOffline ) |
823 { |
773 { |
824 ChangePublisherStatusL( KOffLine ); |
774 actionsToLaunch->AppendL(TLiwVariant( KOffLine )); |
825 } |
775 } |
|
776 |
|
777 ChangePublisherStatusL( actionsToLaunch ); |
|
778 CleanupStack::PopAndDestroy( actionsToLaunch ); |
826 } |
779 } |
827 } |
780 } |
828 |
781 |
829 // --------------------------------------------------------------------------- |
782 // --------------------------------------------------------------------------- |
830 // ResolveSkinItemId |
783 // ResolveSkinItemId |