21 #include "wrtharvesterregistryaccess.h" |
21 #include "wrtharvesterregistryaccess.h" |
22 #include "wrtharvesterpsnotifier.h" |
22 #include "wrtharvesterpsnotifier.h" |
23 #include "wrtharvesterpublisherobserver.h" |
23 #include "wrtharvesterpublisherobserver.h" |
24 |
24 |
25 #include "wrtharvesterconst.h" |
25 #include "wrtharvesterconst.h" |
26 #include <WidgetRegistryConstants.h> |
26 #include <widgetregistryconstants.h> |
27 #include <wrtharvester.rsg> |
27 #include <wrtharvester.rsg> |
28 |
28 #include <startupdomainpskeys.h> |
29 #include <implementationproxy.h> |
29 #include <ecom/implementationproxy.h> |
30 |
30 |
31 #include <liwservicehandler.h> |
31 #include <LiwServiceHandler.h> |
32 #include <liwvariant.h> |
32 #include <LiwVariant.h> |
33 #include <liwgenericparam.h> |
33 #include <LiwGenericParam.h> |
34 #include <e32property.h> //Publish & Subscribe |
34 #include <e32property.h> //Publish & Subscribe |
35 #include <AknTaskList.h> |
35 #include <AknTaskList.h> |
36 #include <apaid.h> |
36 #include <apaid.h> |
37 #include <apacmdln.h> |
37 #include <apacmdln.h> |
38 #include <s32mem.h> |
38 #include <s32mem.h> |
39 #include <apgtask.h> |
39 #include <APGTASK.H> |
40 #include <coemain.h> |
40 #include <coemain.h> |
41 #include <bautils.h> |
41 #include <bautils.h> |
42 #include <f32file.h> |
42 #include <f32file.h> |
43 #include <e32std.h> |
43 #include <e32std.h> |
44 #include <AknNotify.h> |
44 #include <AknNotify.h> |
45 #include <AknGlobalConfirmationQuery.h> |
45 #include <aknglobalconfirmationquery.h> |
46 #include <StringLoader.h> |
46 #include <StringLoader.h> |
47 #include <data_caging_path_literals.hrh> |
47 #include <data_caging_path_literals.hrh> |
|
48 #include <oommonitorsession.h> |
|
49 |
|
50 #ifndef BRDO_OOM_MONITOR2_COMPONENT_FF |
|
51 #include <systemwarninglevels.hrh> |
|
52 #endif |
|
53 #include "browser_platform_variant.hrh" |
48 |
54 |
49 // CONSTANTS |
55 // CONSTANTS |
50 _LIT( KResourceFileName, "\\resource\\wrtharvester.rsc" ); |
56 _LIT( KResourceFileName, "\\resource\\wrtharvester.rsc" ); |
51 _LIT( KResourceDir, "Z:wrtharvester.rsc" ); |
57 _LIT( KResourceDir, "Z:wrtharvester.rsc" ); |
|
58 _LIT( KUid, "uid"); |
|
59 _LIT( K0x, "0x"); |
|
60 _LIT( KOpenPar, "("); |
|
61 _LIT( KClosePar, ")"); |
|
62 _LIT8( KWidgetIcon, "widget_icon"); |
|
63 #define KUidWidgetOOMPlugin 0x10282855 |
|
64 const TInt KMemoryToLaunchWidgetUi = 17*1024*1024; |
|
65 |
|
66 |
|
67 |
|
68 /** |
|
69 * Launch or bring foreground the asked widget. |
|
70 * |
|
71 * Launch widget. |
|
72 * @param aUid UID of the widget. |
|
73 * @param aOperation Operation to perform. |
|
74 */ |
|
75 static void LaunchWidgetL( const TUid& aUid, TUint32 aOperation ); |
|
76 |
|
77 /** |
|
78 * In case the widget cannot be launched because of OOM |
|
79 * Notify harvester and Clear event Queue |
|
80 * @return void |
|
81 */ |
|
82 static void NotifyCommandAndCleanUp(); |
|
83 |
|
84 /** |
|
85 * Launch new widget. |
|
86 * |
|
87 * Launch new widget. |
|
88 * @param aUid UID of the widget. |
|
89 * @param aOperation Operation to perform. |
|
90 */ |
|
91 static void LaunchWidgetUIL( |
|
92 const TUid& aUid, |
|
93 const TDesC8& aMessage, |
|
94 TUint32 aOperation ); |
52 |
95 |
53 /** |
96 /** |
54 * Utility class to show the prompt for platform security access. |
97 * Utility class to show the prompt for platform security access. |
55 * |
98 * |
56 * The class exists only to provide platform security access prompt |
99 * The class exists only to provide platform security access prompt |
129 |
172 |
130 // ---------------------------------------------------------------------------- |
173 // ---------------------------------------------------------------------------- |
131 // Returns the app full name |
174 // Returns the app full name |
132 // ---------------------------------------------------------------------------- |
175 // ---------------------------------------------------------------------------- |
133 // |
176 // |
|
177 /* |
134 static HBufC* GetAppNameLC( RApaLsSession& aSession, const TUid& aUid ) |
178 static HBufC* GetAppNameLC( RApaLsSession& aSession, const TUid& aUid ) |
135 { |
179 { |
136 TApaAppInfo info; |
180 TApaAppInfo info; |
137 User::LeaveIfError( aSession.GetAppInfo( info, aUid ) ); |
181 User::LeaveIfError( aSession.GetAppInfo( info, aUid ) ); |
138 |
182 |
139 return info.iFullName.AllocLC(); |
183 return info.iFullName.AllocLC(); |
140 } |
184 } |
141 |
185 */ |
142 |
186 |
143 // ---------------------------------------------------------------------------- |
|
144 // Sends the command to Widget launcher |
|
145 // ---------------------------------------------------------------------------- |
|
146 // |
|
147 static void HandleWidgetCommandL( |
|
148 RApaLsSession& aSession, |
|
149 const TDesC& aWidget, |
|
150 const TUid& aUid, |
|
151 TUint32 aOperation ) |
|
152 { |
|
153 const TInt size( 2* aWidget.Length() + 3*sizeof( TUint32 ) ); |
|
154 |
|
155 // Message format is <filenameLength><unicode_filename><someintegervalue> |
|
156 CApaCommandLine* cmd( CApaCommandLine::NewLC() ); |
|
157 HBufC8* opaque( HBufC8::NewLC( size ) ); |
|
158 |
|
159 RDesWriteStream stream; |
|
160 TPtr8 des( opaque->Des() ); |
|
161 |
|
162 stream.Open( des ); |
|
163 CleanupClosePushL( stream ); |
|
164 |
|
165 // Generate the command. |
|
166 stream.WriteUint32L( aUid.iUid ); |
|
167 stream.WriteUint32L( aWidget.Length() ); |
|
168 stream.WriteL( reinterpret_cast< const TUint8* >( aWidget.Ptr() ), |
|
169 aWidget.Size() ); |
|
170 |
|
171 stream.WriteInt32L( aOperation ); |
|
172 |
|
173 CleanupStack::PopAndDestroy( &stream ); |
|
174 |
|
175 // Generate command. |
|
176 cmd->SetCommandL( EApaCommandBackgroundAndWithoutViews ); |
|
177 cmd->SetOpaqueDataL( *opaque ); |
|
178 |
|
179 CleanupStack::PopAndDestroy( opaque ); |
|
180 |
|
181 cmd->SetExecutableNameL( KLauncherApp ); |
|
182 |
|
183 User::LeaveIfError( aSession.StartApp( *cmd ) ); |
|
184 CleanupStack::PopAndDestroy( cmd ); |
|
185 } |
|
186 |
|
187 // Map the interface UIDs to implementation factory functions |
187 // Map the interface UIDs to implementation factory functions |
188 const TImplementationProxy ImplementationTable[] = |
188 const TImplementationProxy ImplementationTable[] = |
189 { |
189 { |
190 IMPLEMENTATION_PROXY_ENTRY( 0xA12345FE, CWrtHarvester::NewL ) |
190 IMPLEMENTATION_PROXY_ENTRY( 0xA12345FE, CWrtHarvester::NewL ) |
191 }; |
191 }; |
218 // ---------------------------------------------------------------------------- |
218 // ---------------------------------------------------------------------------- |
219 // |
219 // |
220 void CWrtHarvester::ConstructL() |
220 void CWrtHarvester::ConstructL() |
221 { |
221 { |
222 User::LeaveIfError( iApaSession.Connect() ); |
222 User::LeaveIfError( iApaSession.Connect() ); |
|
223 |
|
224 iSystemShutdown = EFalse; |
223 iWidgetUIListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetUIState ); |
225 iWidgetUIListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetUIState ); |
224 iWidgetRegListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetRegAltered ); |
226 iWidgetRegListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetRegAltered ); |
|
227 iWidgetSystemShutdownListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetSystemShutdown ); |
|
228 iMsModeListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetMassStorageMode ); |
225 |
229 |
226 User::LeaveIfError( iFs.Connect() ); |
230 User::LeaveIfError( iFs.Connect() ); |
227 iWidgetUsbListener = CWrtUsbHandler::NewL( this, iFs ); |
231 |
228 |
|
229 iWidgetUsbListener->Start(); |
|
230 SetMSMode(0); |
232 SetMSMode(0); |
231 |
233 |
|
234 iCanAccessRegistry = ETrue; |
|
235 iReinstallingWidget = EFalse; |
|
236 |
|
237 |
232 TFileName resourceFileName; |
238 TFileName resourceFileName; |
233 TParse parse; |
239 TParse parse; |
234 Dll::FileName (resourceFileName); |
240 Dll::FileName (resourceFileName); |
235 parse.Set(KResourceFileName, &resourceFileName, NULL); |
241 parse.Set(KResourceFileName, &resourceFileName, NULL); |
236 resourceFileName = parse.FullName(); |
242 resourceFileName = parse.FullName(); |
272 CCoeEnv::Static()->DeleteResourceFile( iResourceFileOffset ); |
278 CCoeEnv::Static()->DeleteResourceFile( iResourceFileOffset ); |
273 } |
279 } |
274 iObservers.ResetAll(); |
280 iObservers.ResetAll(); |
275 iWidgetInfo.ResetAll(); |
281 iWidgetInfo.ResetAll(); |
276 iWidgetStateArray.ResetAll(); |
282 iWidgetStateArray.ResetAll(); |
|
283 |
277 delete iWidgetUIListener; |
284 delete iWidgetUIListener; |
278 delete iWidgetRegListener; |
285 delete iWidgetRegListener; |
279 delete iWidgetMMCListener; |
286 delete iMsModeListener; |
280 delete iWidgetUsbListener; |
287 delete iWidgetSystemShutdownListener; |
|
288 |
|
289 if(iAsyncCallBack) |
|
290 { |
|
291 iAsyncCallBack->Cancel(); |
|
292 } |
|
293 delete iAsyncCallBack; |
|
294 iAsyncCallBack = NULL; |
|
295 iUid.Close(); |
281 iWidgetOperations.Close(); |
296 iWidgetOperations.Close(); |
282 iHSWidgets.ResetAndDestroy(); |
297 iHSWidgets.ResetAndDestroy(); |
283 iApaSession.Close(); |
298 iApaSession.Close(); |
284 } |
299 } |
285 |
300 |
298 // |
313 // |
299 void CWrtHarvester::HandlePublisherNotificationL( const TDesC& aContentId, const TDesC8& aTrigger ) |
314 void CWrtHarvester::HandlePublisherNotificationL( const TDesC& aContentId, const TDesC8& aTrigger ) |
300 { |
315 { |
301 |
316 |
302 //Do not send the Operations to the Widgets when in Mass storage mode.. . . |
317 //Do not send the Operations to the Widgets when in Mass storage mode.. . . |
|
318 TUid uid( WidgetUid( aContentId ) ); |
|
319 |
|
320 |
|
321 if(iSystemShutdown && aTrigger == KDeActive ) |
|
322 { |
|
323 return ; |
|
324 } |
303 if( IsInMSMode() == 1 ) |
325 if( IsInMSMode() == 1 ) |
304 { |
326 { |
305 if(aTrigger == KDeActive) |
327 if( aTrigger == KDeActive && !iSystemShutdown ) |
306 RemovePublisherAndObserverL(aContentId); |
328 { |
307 return; |
329 RemovePublisherAndObserverL(aContentId); |
308 } |
330 RWidgetRegistryClientSession session; |
309 |
331 CleanupClosePushL( session ); |
310 TUid uid( WidgetUid( aContentId ) ); |
332 User::LeaveIfError( session.Connect() ); |
|
333 session.SetBlanketPermissionL( uid, EBlanketUnknown ); |
|
334 CleanupStack::PopAndDestroy( &session ); |
|
335 } |
|
336 return; |
|
337 } |
|
338 |
|
339 if(!iCanAccessRegistry) |
|
340 return; |
|
341 |
311 TWidgetOperations operation( Uninitialized ); |
342 TWidgetOperations operation( Uninitialized ); |
312 if( aTrigger == KActive ) |
343 if( aTrigger == KActive ) |
313 { |
344 { |
314 HBufC* temp = aContentId.Alloc(); |
345 HBufC* temp = aContentId.Alloc(); |
315 iHSWidgets.Append( temp ); |
346 iHSWidgets.Append( temp ); |
479 variant.Reset(); |
527 variant.Reset(); |
480 |
528 |
481 if( publisherMap && publisherMap->FindL( KContentId , variant )) |
529 if( publisherMap && publisherMap->FindL( KContentId , variant )) |
482 { |
530 { |
483 HBufC* bundleId = variant.AsDes().AllocLC(); |
531 HBufC* bundleId = variant.AsDes().AllocLC(); |
484 publishers.AppendL( bundleId ); |
532 variant.Reset(); |
485 CleanupStack::Pop( bundleId ); |
533 TBool isNokiaWidget = EFalse; |
|
534 if ( publisherMap->FindL( KDataMap, variant) ) |
|
535 { |
|
536 CLiwDefaultMap* dataMap = CLiwDefaultMap::NewLC(); |
|
537 variant.Get( *dataMap ); |
|
538 variant.Reset(); |
|
539 if ( dataMap->FindL( KWidgetInfo, variant ) ) |
|
540 { |
|
541 CLiwDefaultMap* widgetInfoMap = CLiwDefaultMap::NewLC(); |
|
542 variant.Get( *widgetInfoMap ); |
|
543 if ( widgetInfoMap->FindL( KWidgetType, variant ) ) |
|
544 { |
|
545 if ( KS60Widget == variant.AsTInt32()) |
|
546 { |
|
547 isNokiaWidget = ETrue; |
|
548 } |
|
549 } |
|
550 CleanupStack::PopAndDestroy( widgetInfoMap ); |
|
551 } |
|
552 CleanupStack::PopAndDestroy( dataMap ); |
|
553 } |
|
554 |
|
555 if (isNokiaWidget ) |
|
556 { |
|
557 publishers.AppendL( bundleId ); |
|
558 CleanupStack::Pop( bundleId ); |
|
559 } |
|
560 else |
|
561 { |
|
562 CleanupStack::PopAndDestroy( bundleId ); |
|
563 } |
486 } |
564 } |
487 CleanupStack::PopAndDestroy( publisherMap ); |
565 CleanupStack::PopAndDestroy( publisherMap ); |
488 } |
566 } |
489 |
567 |
490 variant.Reset(); |
568 variant.Reset(); |
501 TBool networkAccess = CheckNetworkAccessL( wrtInfo.iUid ); |
579 TBool networkAccess = CheckNetworkAccessL( wrtInfo.iUid ); |
502 |
580 |
503 __UHEAP_MARK; |
581 __UHEAP_MARK; |
504 TInt id( KErrNotFound ); |
582 TInt id( KErrNotFound ); |
505 if( iCPSInterface ) |
583 if( iCPSInterface ) |
506 { |
584 { |
|
585 TBuf<10> uid(wrtInfo.iUid.Name()); // [12345678] |
|
586 uid.Delete(0,1); // 12345678] |
|
587 uid.Delete( uid.Length()-1, 1); // 12345678 |
|
588 TBuf<50> wrtuid; |
|
589 wrtuid.Append(KUid); // uid |
|
590 wrtuid.Append(KOpenPar); // uid( |
|
591 wrtuid.Append(K0x); // uid(0x |
|
592 wrtuid.Append(uid ); // uid(0x12345678 |
|
593 wrtuid.Append(KClosePar); // uid(0x12345678) |
|
594 |
507 CLiwGenericParamList* inparam( CLiwGenericParamList::NewLC() ); |
595 CLiwGenericParamList* inparam( CLiwGenericParamList::NewLC() ); |
508 CLiwGenericParamList* outparam( CLiwGenericParamList::NewLC() ); |
596 CLiwGenericParamList* outparam( CLiwGenericParamList::NewLC() ); |
509 |
597 |
510 TLiwGenericParam type( KType, TLiwVariant( KPubData )); |
598 TLiwGenericParam type( KType, TLiwVariant( KPubData )); |
511 inparam->AppendL( type ); |
599 inparam->AppendL( type ); |
515 |
603 |
516 // Create the data map for publisher registry |
604 // Create the data map for publisher registry |
517 cpdatamap->InsertL( KPublisherId, TLiwVariant( KWRTPublisher )); |
605 cpdatamap->InsertL( KPublisherId, TLiwVariant( KWRTPublisher )); |
518 cpdatamap->InsertL( KContentType, TLiwVariant( KTemplatedWidget )); |
606 cpdatamap->InsertL( KContentType, TLiwVariant( KTemplatedWidget )); |
519 cpdatamap->InsertL( KContentId, TLiwVariant( wrtInfo.iBundleId )); |
607 cpdatamap->InsertL( KContentId, TLiwVariant( wrtInfo.iBundleId )); |
|
608 |
520 // Widget info map |
609 // Widget info map |
521 CLiwDefaultMap* widgetInfo = CLiwDefaultMap::NewLC(); |
610 CLiwDefaultMap* widgetInfo = CLiwDefaultMap::NewLC(); |
522 widgetInfo->InsertL( KTemplateType, TLiwVariant( KTemplateName )); |
611 widgetInfo->InsertL( KTemplateType, TLiwVariant( KTemplateName )); |
523 widgetInfo->InsertL( KWidgetName, TLiwVariant( wrtInfo.iDisplayName )); |
612 widgetInfo->InsertL( KWidgetName, TLiwVariant( wrtInfo.iDisplayName )); |
524 datamap->InsertL( KWidgetInfo , TLiwVariant( widgetInfo )); |
613 widgetInfo->InsertL( KWidgetIcon, TLiwVariant( wrtuid)); // uid(0x12345678) This is the expected format |
525 CleanupStack::PopAndDestroy( widgetInfo ); |
614 widgetInfo->InsertL( KWidgetType, TLiwVariant( TInt32 (wrtInfo.iType ) )); |
526 |
615 |
527 // Take dynamic menu items into use |
616 datamap->InsertL( KWidgetInfo , TLiwVariant( widgetInfo )); |
528 if (networkAccess) |
617 CleanupStack::PopAndDestroy( widgetInfo ); |
529 { |
618 |
530 CLiwDefaultMap* mapMenu = CLiwDefaultMap::NewLC(); |
619 // Take dynamic menu items into use |
531 mapMenu->InsertL( KItemOnlineOffline, TLiwVariant( KMyActionName )); |
620 if (networkAccess) |
532 datamap->InsertL( KMenuItems, TLiwVariant( mapMenu )); |
621 { |
533 CleanupStack::PopAndDestroy(mapMenu); |
622 CLiwDefaultMap* mapMenu = CLiwDefaultMap::NewLC(); |
534 } |
623 mapMenu->InsertL( KItemOnlineOffline, TLiwVariant( KMyActionName )); |
|
624 datamap->InsertL( KMenuItems, TLiwVariant( mapMenu )); |
|
625 CleanupStack::PopAndDestroy(mapMenu); |
|
626 } |
535 |
627 |
536 cpdatamap->InsertL( KDataMap, TLiwVariant(datamap) ); |
628 cpdatamap->InsertL( KDataMap, TLiwVariant(datamap) ); |
537 |
629 |
538 // Create the action map for publisher registry |
630 // Create the action map for publisher registry |
539 actionmap = CLiwDefaultMap::NewLC(); |
631 actionmap = CLiwDefaultMap::NewLC(); |
678 // ---------------------------------------------------------------------------- |
770 // ---------------------------------------------------------------------------- |
679 // |
771 // |
680 void CWrtHarvester::QueueOperationL( TWidgetOperations aOperation, TUid aUid ) |
772 void CWrtHarvester::QueueOperationL( TWidgetOperations aOperation, TUid aUid ) |
681 { |
773 { |
682 //Hack to find out if WidgetUi exist as Queue keeps filling up |
774 //Hack to find out if WidgetUi exist as Queue keeps filling up |
683 if((iHSCount*3 <= iWidgetOperations.Count() && !CheckTaskExistsL()) || (aOperation == WidgetSelect)) |
775 SWidgetOperation op = { aOperation, aUid }; |
684 { |
776 |
|
777 TInt value = KErrNone; |
|
778 TInt error = iWidgetUIListener->GetValue(value); |
|
779 |
|
780 if((iHSCount*3 <= iWidgetOperations.Count() && !CheckTaskExistsL() ) || (aOperation == WidgetSelect && !CheckTaskExistsL() && value ) ) |
|
781 { |
685 ClearAllOperations(); |
782 ClearAllOperations(); |
686 iWidgetUIListener->SetValue(1); |
783 iWidgetUIListener->SetValue(1); |
687 } |
784 } |
688 SWidgetOperation op = { aOperation, aUid }; |
785 |
689 iWidgetOperations.Append( op ); |
786 TBool queued (EFalse); |
|
787 for(TInt i =0; i < iWidgetOperations.Count() && (aOperation == WidgetResume || aOperation == WidgetSuspend ) ; i++) |
|
788 { |
|
789 SWidgetOperation opInQueue = iWidgetOperations[i]; |
|
790 //we get resume but we already have suspend in Queue |
|
791 //make Resume as Suspend |
|
792 if(op.iOperation == WidgetResume && opInQueue.iUid == op.iUid && opInQueue.iOperation == WidgetSuspend ) |
|
793 { |
|
794 iWidgetOperations[i].iOperation = WidgetResume; |
|
795 queued = ETrue; |
|
796 break; |
|
797 } |
|
798 //we get suspend but we already have resume in Queue |
|
799 //make Suspend as Resume |
|
800 if(op.iOperation == WidgetSuspend && opInQueue.iUid == op.iUid && opInQueue.iOperation == WidgetResume ) |
|
801 { |
|
802 iWidgetOperations[i].iOperation = WidgetSuspend; |
|
803 queued = ETrue; |
|
804 break; |
|
805 } |
|
806 } |
|
807 |
|
808 if(!queued) |
|
809 iWidgetOperations.Append( op ); |
|
810 |
690 TryLaunchNextOperationL(); |
811 TryLaunchNextOperationL(); |
691 } |
812 } |
692 |
813 |
693 // ---------------------------------------------------------------------------- |
814 // ---------------------------------------------------------------------------- |
694 // |
815 // |
714 // |
835 // |
715 void CWrtHarvester::TryLaunchNextOperationL() |
836 void CWrtHarvester::TryLaunchNextOperationL() |
716 { |
837 { |
717 TInt value = KErrNone; |
838 TInt value = KErrNone; |
718 TInt error = iWidgetUIListener->GetValue(value); |
839 TInt error = iWidgetUIListener->GetValue(value); |
719 if( error == KErrNone && value == 1 && iWidgetOperations.Count() != 0 ) |
840 if( error == KErrNone && value == 1 && iWidgetOperations.Count() != 0 && iCanAccessRegistry ) |
720 { |
841 { |
721 // Set value to 0 so that next widget is not launched before Widget App sets value to 1. |
842 // Set value to 0 so that next widget is not launched before Widget App sets value to 1. |
722 iWidgetUIListener->SetValue( 0 ); |
843 iWidgetUIListener->SetValue( 0 ); |
723 //Always launch the first in operation |
844 //Always launch the first in operation |
724 LaunchWidgetOperationL( iWidgetOperations[0] ); |
845 LaunchWidgetOperationL( iWidgetOperations[0] ); |
725 iWidgetOperations.Remove( 0 ); |
846 |
|
847 if(iWidgetOperations[0].iOperation == WidgetSelect) |
|
848 ClearAllOperations(); |
|
849 else |
|
850 iWidgetOperations.Remove( 0 ); |
726 } |
851 } |
727 } |
852 } |
728 |
853 |
729 void CWrtHarvester::ClearAllOperations() |
854 void CWrtHarvester::ClearAllOperations() |
730 { |
855 { |
793 void CWrtHarvester::QueueResumeL( TUid& aUid ) |
916 void CWrtHarvester::QueueResumeL( TUid& aUid ) |
794 { |
917 { |
795 RWidgetRegistryClientSession session; |
918 RWidgetRegistryClientSession session; |
796 CleanupClosePushL( session ); |
919 CleanupClosePushL( session ); |
797 User::LeaveIfError( session.Connect() ); |
920 User::LeaveIfError( session.Connect() ); |
798 if ( session.IsBlanketPermGranted ( aUid ) == EBlanketUnknown && !iDialogShown ) |
921 |
|
922 CWidgetPropertyValue* property = session.GetWidgetPropertyValueL( aUid, EPreInstalled ); |
|
923 TBool preInstalled = property && *(property); |
|
924 delete property; |
|
925 |
|
926 // Set blanket permission to true for pre-installed widgets |
|
927 if ( preInstalled ) |
|
928 { |
|
929 session.SetBlanketPermissionL( aUid, EBlanketTrue ); |
|
930 } |
|
931 |
|
932 if ( session.IsBlanketPermGranted ( aUid ) == EBlanketUnknown && !iDialogShown |
|
933 && iCanAccessRegistry ) |
799 { |
934 { |
800 iDialogShown = ETrue; |
935 iDialogShown = ETrue; |
801 AllowPlatformAccessL( aUid ); |
936 AllowPlatformAccessL( aUid ); |
802 } |
937 } |
803 else if(!iDialogShown) |
938 else if(session.IsBlanketPermGranted ( aUid ) == EBlanketUnknown) |
|
939 { |
|
940 iUid.Append(aUid); |
|
941 } |
|
942 else |
804 { |
943 { |
805 QueueOperationL( WidgetResume, aUid ); |
944 QueueOperationL( WidgetResume, aUid ); |
806 } |
945 } |
807 CleanupStack::PopAndDestroy( &session ); |
946 CleanupStack::PopAndDestroy( &session ); |
808 } |
947 } |
872 TBool CWrtHarvester::CheckNetworkAccessL( TUid& aUid ) |
1011 TBool CWrtHarvester::CheckNetworkAccessL( TUid& aUid ) |
873 { |
1012 { |
874 RWidgetRegistryClientSession session; |
1013 RWidgetRegistryClientSession session; |
875 CleanupClosePushL( session ); |
1014 CleanupClosePushL( session ); |
876 User::LeaveIfError( session.Connect() ); |
1015 User::LeaveIfError( session.Connect() ); |
877 TBool networkAccess = *(session.GetWidgetPropertyValueL( aUid, EAllowNetworkAccess ) ); |
1016 |
|
1017 CWidgetPropertyValue* value = session.GetWidgetPropertyValueL( aUid, EAllowNetworkAccess ); |
|
1018 TBool networkAccess = value && *(value); |
|
1019 delete value; |
|
1020 |
878 CleanupStack::PopAndDestroy( &session ); |
1021 CleanupStack::PopAndDestroy( &session ); |
879 |
1022 |
880 return networkAccess; |
1023 return networkAccess; |
|
1024 } |
|
1025 // ---------------------------------------------------------------------------- |
|
1026 // |
|
1027 // ---------------------------------------------------------------------------- |
|
1028 // |
|
1029 TInt CWrtHarvester::DeleteCallback(TAny* aPtr) |
|
1030 { |
|
1031 CWrtHarvester* self = (CWrtHarvester*)aPtr; |
|
1032 self->QueueResumeL(self->iUid[0]); |
|
1033 self->iUid.Remove(0); |
|
1034 delete self->iAsyncCallBack; |
|
1035 self->iAsyncCallBack = NULL; |
|
1036 return 0; |
|
1037 } |
|
1038 |
|
1039 // ---------------------------------------------------------------------------- |
|
1040 // |
|
1041 // ---------------------------------------------------------------------------- |
|
1042 // |
|
1043 void CWrtHarvester::DialogShown() |
|
1044 { |
|
1045 iDialogShown = EFalse; |
|
1046 if(iUid.Count()) |
|
1047 { |
|
1048 iAsyncCallBack = new (ELeave) CAsyncCallBack(TCallBack(DeleteCallback,this),CActive::EPriorityUserInput); |
|
1049 iAsyncCallBack->CallBack(); |
|
1050 } |
881 } |
1051 } |
882 |
1052 |
883 // ---------------------------------------------------------------------------- |
1053 // ---------------------------------------------------------------------------- |
884 // |
1054 // |
885 // ---------------------------------------------------------------------------- |
1055 // ---------------------------------------------------------------------------- |
991 iGlobalConfirmationQuery->ShowConfirmationQueryL |
1161 iGlobalConfirmationQuery->ShowConfirmationQueryL |
992 (iStatus, |
1162 (iStatus, |
993 aMessage, |
1163 aMessage, |
994 aSoftkeys); |
1164 aSoftkeys); |
995 } |
1165 } |
996 |
1166 //====================================================================== |
|
1167 // Launch widget. |
|
1168 //=========================================================================== |
|
1169 // |
|
1170 void LaunchWidgetL( const TUid& aUid, TUint32 aOperation ) |
|
1171 { |
|
1172 __UHEAP_MARK; |
|
1173 |
|
1174 TUid widgetAppUid( TUid::Uid( KWidgetAppUid ) ); |
|
1175 |
|
1176 RWsSession wsSession; |
|
1177 ROomMonitorSession monitorSession; |
|
1178 TApaTaskList taskList( wsSession ); |
|
1179 HBufC8* message( HBufC8::NewLC( KWidgetUiMaxMessageLength ) ); |
|
1180 TPtr8 des( message->Des() ); |
|
1181 TInt err(KErrNone); |
|
1182 RDesWriteStream stream( des ); |
|
1183 |
|
1184 CleanupClosePushL( stream ); |
|
1185 |
|
1186 // Make the message to be sent. |
|
1187 stream.WriteUint32L( 1 ); |
|
1188 stream.WriteUint32L( aUid.iUid ); |
|
1189 stream.WriteInt32L( aOperation ); |
|
1190 |
|
1191 CleanupStack::PopAndDestroy( &stream ); |
|
1192 |
|
1193 // Create Window server session |
|
1194 User::LeaveIfError( wsSession.Connect() ); |
|
1195 User::LeaveIfError( monitorSession.Connect() ); |
|
1196 CleanupClosePushL( wsSession ); |
|
1197 |
|
1198 // Get the task list |
|
1199 // Try to find out if stub ui is already running |
|
1200 TApaTask task = taskList.FindApp( widgetAppUid ); |
|
1201 |
|
1202 if ( task.Exists() ) |
|
1203 { |
|
1204 // TODO make something here, or not... |
|
1205 widgetAppUid = TUid::Uid( 1 ); |
|
1206 if ( aOperation == WidgetSelect ) |
|
1207 { |
|
1208 task.BringToForeground(); |
|
1209 } |
|
1210 task.SendMessage( widgetAppUid, des ); |
|
1211 } |
|
1212 else |
|
1213 { |
|
1214 // TODO CONST |
|
1215 if ( aOperation == LaunchMiniview || |
|
1216 aOperation == WidgetSelect || |
|
1217 aOperation == WidgetResume || |
|
1218 aOperation == WidgetRestart ) //WidgetUI has died -> re-launch |
|
1219 { |
|
1220 TInt bytesAvailaible(0); |
|
1221 if (aOperation != WidgetSelect ) |
|
1222 { |
|
1223 #ifdef BRDO_OOM_MONITOR2_COMPONENT_FF |
|
1224 err = monitorSession.RequestOptionalRam(KMemoryToLaunchWidgetUi, KMemoryToLaunchWidgetUi,KUidWidgetOOMPlugin, bytesAvailaible); |
|
1225 #else |
|
1226 TMemoryInfoV1Buf info; |
|
1227 UserHal::MemoryInfo(info); |
|
1228 err = info().iFreeRamInBytes > KMemoryToLaunchWidgetUi + KRAMGOODTHRESHOLD ? KErrNone : KErrNoMemory; |
|
1229 #endif |
|
1230 if( err == KErrNone) |
|
1231 { |
|
1232 LaunchWidgetUIL( widgetAppUid, *message, aOperation ); |
|
1233 } |
|
1234 } |
|
1235 else |
|
1236 { |
|
1237 //The modification is related to the manual starting of WRT widgets from HS. After noticing an issue when |
|
1238 //the user taps manually a WRT widget from the HS. |
|
1239 //If RAM is not available with RequestOptionalRam() API, the manual tapping does nothing |
|
1240 //and that is incorrect behaviour. Therefore if widgetSelect -event is sent to the launcher we are using RequestFreeMemory() instead of using RequestOptionalRam() API. |
|
1241 //This means that we apply mandatory RAM allocation when a widget is started manually from HS in order to make sure that RAM is released properly |
|
1242 err = monitorSession.RequestFreeMemory( KMemoryToLaunchWidgetUi ); |
|
1243 if( err == KErrNone) |
|
1244 { |
|
1245 LaunchWidgetUIL( widgetAppUid, *message, aOperation ); |
|
1246 } |
|
1247 } |
|
1248 if(err != KErrNone) |
|
1249 NotifyCommandAndCleanUp(); |
|
1250 } |
|
1251 else |
|
1252 { |
|
1253 NotifyCommandAndCleanUp(); |
|
1254 } |
|
1255 |
|
1256 } |
|
1257 |
|
1258 CleanupStack::PopAndDestroy( 2, message ); |
|
1259 monitorSession.Close(); |
|
1260 __UHEAP_MARKEND; |
|
1261 } |
|
1262 |
|
1263 //=========================================================================== |
|
1264 // Launch Widget UI. |
|
1265 //=========================================================================== |
|
1266 void LaunchWidgetUIL( |
|
1267 const TUid& aUid, |
|
1268 const TDesC8& aMessage, |
|
1269 TUint32 aOperation ) |
|
1270 { |
|
1271 HBufC* document( NULL ); |
|
1272 CApaCommandLine* line( CApaCommandLine::NewLC() ); |
|
1273 TApaAppInfo info; |
|
1274 RApaLsSession session; |
|
1275 |
|
1276 User::LeaveIfError( session.Connect() ); |
|
1277 CleanupClosePushL( session ); |
|
1278 |
|
1279 User::LeaveIfError( session.GetAppInfo( info, aUid ) ); |
|
1280 |
|
1281 document = HBufC::NewMaxLC( TReal( TReal( aMessage.Length() ) / 2.0 ) + 0.5 ); |
|
1282 |
|
1283 Mem::Copy( |
|
1284 reinterpret_cast< TUint8* >( const_cast< TUint16* >( document->Ptr() ) ), |
|
1285 aMessage.Ptr(), |
|
1286 KWidgetUiMaxMessageLength ); |
|
1287 |
|
1288 line->SetDocumentNameL( *document ); |
|
1289 line->SetExecutableNameL( info.iFullName ); |
|
1290 |
|
1291 // TODO make const definitions. |
|
1292 if ( aOperation == 1 || aOperation == 3 ) |
|
1293 { |
|
1294 line->SetCommandL( EApaCommandBackground ); |
|
1295 } |
|
1296 |
|
1297 session.StartApp( *line ); |
|
1298 |
|
1299 CleanupStack::PopAndDestroy( 3, line ); |
|
1300 } |
|
1301 |
|
1302 void NotifyCommandAndCleanUp() |
|
1303 { |
|
1304 const TUid KMyPropertyCat = { 0x10282E5A }; |
|
1305 enum TMyPropertyKeys { EWidgetUIState = 109 }; |
|
1306 TInt state( 2 ); |
|
1307 RProperty::Set( KMyPropertyCat, EWidgetUIState , state ); |
|
1308 } |
997 // End of File |
1309 // End of File |