155 iDeferredPublish = new (ELeave) CAsyncCallBack(TCallBack(DoPublish, this), |
155 iDeferredPublish = new (ELeave) CAsyncCallBack(TCallBack(DoPublish, this), |
156 CActive::EPriorityLow); |
156 CActive::EPriorityLow); |
157 |
157 |
158 MPX_DEBUG1("CMusicContentPublisher::ConstructL subscribing to observer"); |
158 MPX_DEBUG1("CMusicContentPublisher::ConstructL subscribing to observer"); |
159 |
159 |
|
160 // Observer must be registered before the publisher |
|
161 // When publisher is registered, HS gets the notification and starts sending the events immediately. |
|
162 // Late registration of observer causes missing events. |
|
163 |
|
164 // 1. Register the Observer |
|
165 CLiwDefaultMap* filter = CLiwDefaultMap::NewLC(); |
|
166 filter->InsertL( KPublisherId, TLiwVariant( KMWPublisher ) ); |
|
167 filter->InsertL( KContentId, TLiwVariant( KAll) ); |
|
168 filter->InsertL( KContentType, TLiwVariant( KAll ) ); |
|
169 iHPObserver = CMCPHarvesterPublisherObserver::NewL(this); |
|
170 iHPObserver->RegisterL(filter); |
|
171 CleanupStack::PopAndDestroy(filter); |
|
172 |
|
173 // 2. Register the Publisher |
160 TUint id = RegisterPublisherL( |
174 TUint id = RegisterPublisherL( |
161 KMWPublisher, |
175 KMWPublisher, |
162 KAll, |
176 KAll, |
163 KAll ); |
177 KAll ); |
164 |
|
165 if( id != 0 ) |
|
166 { |
|
167 CLiwDefaultMap* filter = CLiwDefaultMap::NewLC(); |
|
168 |
|
169 filter->InsertL( KPublisherId, TLiwVariant( KMWPublisher ) ); |
|
170 filter->InsertL( KContentId, TLiwVariant( KAll) ); |
|
171 filter->InsertL( KContentType, TLiwVariant( KAll ) ); |
|
172 |
|
173 iHPObserver = CMCPHarvesterPublisherObserver::NewL(this); |
|
174 iHPObserver->RegisterL(filter); |
|
175 CleanupStack::PopAndDestroy(filter); |
|
176 } |
|
177 |
178 |
178 MPX_DEBUG1("CMusicContentPublisher::ConstructL initializing content"); |
179 MPX_DEBUG1("CMusicContentPublisher::ConstructL initializing content"); |
179 PublishDefaultL(); |
180 PublishDefaultL(); |
180 |
181 |
181 MPX_DEBUG1("CMusicContentPublisher::ConstructL --->"); |
182 MPX_DEBUG1("CMusicContentPublisher::ConstructL --->"); |
852 iWidgetForeground = EFalse; |
853 iWidgetForeground = EFalse; |
853 } |
854 } |
854 else if ( aTrigger == KMyResume && !iWidgetForeground) |
855 else if ( aTrigger == KMyResume && !iWidgetForeground) |
855 { |
856 { |
856 iWidgetForeground = ETrue; |
857 iWidgetForeground = ETrue; |
857 if ( !iInstanceId ) |
858 DoPublishModifiedL(); |
858 { |
|
859 // CPS framework does not always send 'active' message during boot |
|
860 iInstanceId = aContentId.AllocL(); |
|
861 DoPublishAllL(); |
|
862 } |
|
863 else |
|
864 { |
|
865 DoPublishModifiedL(); |
|
866 } |
|
867 } |
859 } |
868 MPX_DEBUG1("<--CMusicContentPublisher::HandlePublisherNotificationL"); |
860 MPX_DEBUG1("<--CMusicContentPublisher::HandlePublisherNotificationL"); |
869 } |
861 } |
870 |
862 |
871 |
863 |