27 #include <SWInstTaskManager.h> |
27 #include <SWInstTaskManager.h> |
28 #include <SWInstTask.h> |
28 #include <SWInstTask.h> |
29 #include <SWInstLogTaskParam.h> |
29 #include <SWInstLogTaskParam.h> |
30 #include <apacmdln.h> |
30 #include <apacmdln.h> |
31 #include <s32mem.h> |
31 #include <s32mem.h> |
32 #include <e32property.h> |
|
33 |
32 |
34 #include <widgetappdefs.rh> |
33 #include <widgetappdefs.rh> |
35 #include "WidgetUIOperationsWatcher.h" |
34 #include "WidgetUIOperationsWatcher.h" |
36 #include "WidgetUIConfigHandler.h" // info.plist parser |
35 #include "WidgetUIConfigHandler.h" // info.plist parser |
37 #include "WidgetRegistrationManager.h" // interface to "shell" |
36 #include "WidgetRegistrationManager.h" // interface to "shell" |
59 // not drive). The widget bundle must contain relative paths. The |
58 // not drive). The widget bundle must contain relative paths. The |
60 // drive letter is separated because support for multiple drives and |
59 // drive letter is separated because support for multiple drives and |
61 // removable memory cards means that drive letters may change. |
60 // removable memory cards means that drive letters may change. |
62 |
61 |
63 |
62 |
64 static void NotifyCommandHandled() |
|
65 { |
|
66 const TUid KMyPropertyCat = { 0x10282E5A }; |
|
67 enum TMyPropertyKeys { EMyPropertyState = 109 }; |
|
68 TInt state( 3 ); |
|
69 RProperty::Set( KMyPropertyCat, EMyPropertyState , state ); |
|
70 } |
|
71 |
|
72 using namespace SwiUI; |
63 using namespace SwiUI; |
73 |
64 |
74 // =========================== MEMBER FUNCTIONS =============================== |
65 // =========================== MEMBER FUNCTIONS =============================== |
75 |
66 |
76 |
67 |
131 for ( ; i < EWidgetPropertyIdCount; ++i ) |
122 for ( ; i < EWidgetPropertyIdCount; ++i ) |
132 { |
123 { |
133 CWidgetPropertyValue* value = CWidgetPropertyValue::NewL(); |
124 CWidgetPropertyValue* value = CWidgetPropertyValue::NewL(); |
134 User::LeaveIfError( iPropertyValues.Insert( value, i ) ); |
125 User::LeaveIfError( iPropertyValues.Insert( value, i ) ); |
135 } |
126 } |
136 *(iPropertyValues[EWidgetPropertyListVersion]) = KWidgetPropertyListVersion71; |
127 *(iPropertyValues[EWidgetPropertyListVersion]) = WIDGETPROPERTYLISTVERSION; |
137 |
128 |
138 iTaskManager = CTaskManager::NewL(); |
129 iTaskManager = CTaskManager::NewL(); |
139 } |
130 } |
140 |
131 |
141 // ============================================================================ |
132 // ============================================================================ |
183 // ============================================================================ |
174 // ============================================================================ |
184 // |
175 // |
185 void CWidgetUIOperationsWatcher::SilentInstallL( |
176 void CWidgetUIOperationsWatcher::SilentInstallL( |
186 RFile& aFile, |
177 RFile& aFile, |
187 const TDesC8& aMIME, |
178 const TDesC8& aMIME, |
188 TChar& aDrive, |
|
189 TRequestStatus& aRequestStatus ) |
179 TRequestStatus& aRequestStatus ) |
190 { |
180 { |
191 iSilent = ETrue; |
181 iSilent = ETrue; |
192 iRfs.CharToDrive(aDrive,iDrive); |
|
193 InstallL( aFile, aMIME, aRequestStatus ); |
182 InstallL( aFile, aMIME, aRequestStatus ); |
194 } |
183 } |
195 |
184 |
196 // ============================================================================ |
185 // ============================================================================ |
197 // CWidgetUIOperationsWatcher::InstallSubfunctionL() |
186 // CWidgetUIOperationsWatcher::InstallSubfunctionL() |
215 TBool replaceExisting = PreprocessWidgetBundleL(); |
204 TBool replaceExisting = PreprocessWidgetBundleL(); |
216 |
205 |
217 if ( PromptUserForInstallL( replaceExisting ) |
206 if ( PromptUserForInstallL( replaceExisting ) |
218 && PromptUserForUntrustedWidgetL( ) ) |
207 && PromptUserForUntrustedWidgetL( ) ) |
219 { |
208 { |
220 if ( replaceExisting ) |
|
221 { |
|
222 //Runnning widget should be first closed |
|
223 RApaLsSession apaLsSession; |
|
224 apaLsSession.Connect(); |
|
225 TApaAppInfo info; |
|
226 TUid aUid = TUid::Uid( *(iPropertyValues[EUid]) ); |
|
227 |
|
228 User::LeaveIfError( apaLsSession.GetAppInfo( info, aUid ) ); |
|
229 iWidgetName = info.iFullName; |
|
230 HBufC *widgetName = iWidgetName.AllocLC(); |
|
231 if(iWidgetInHS) |
|
232 NotifyCommandHandled(); |
|
233 |
|
234 HandleWidgetCommandL(apaLsSession, *widgetName, aUid, Deactivate); |
|
235 |
|
236 CleanupStack::PopAndDestroy( widgetName ); |
|
237 apaLsSession.Close(); |
|
238 } |
|
239 |
|
240 |
|
241 // reinitialize |
209 // reinitialize |
242 delete iMembers; |
210 delete iMembers; |
243 iMembers = NULL; |
211 iMembers = NULL; |
244 iMembers = iZipFile->GetMembersL(); |
212 iMembers = iZipFile->GetMembersL(); |
245 |
213 |
303 userCancel = ETrue; |
271 userCancel = ETrue; |
304 |
272 |
305 if ( !iSilent ) { iUIHandler->DisplayCancelL(); } |
273 if ( !iSilent ) { iUIHandler->DisplayCancelL(); } |
306 |
274 |
307 TRequestStatus* status = &aRequestStatus; |
275 TRequestStatus* status = &aRequestStatus; |
308 User::RequestComplete( status, KErrCancel ); |
276 User::RequestComplete( status, KErrNone ); |
309 } |
277 } |
310 } |
278 } |
311 |
279 |
312 // ============================================================================ |
280 // ============================================================================ |
313 // CWidgetUIOperationsWatcher::InstallL() |
281 // CWidgetUIOperationsWatcher::InstallL() |
477 *(iPropertyValues[EUid]) = iRegistry.GetWidgetUidL( |
445 *(iPropertyValues[EUid]) = iRegistry.GetWidgetUidL( |
478 *(iPropertyValues[EBundleIdentifier])); |
446 *(iPropertyValues[EBundleIdentifier])); |
479 found = ETrue; |
447 found = ETrue; |
480 TUid aUid = TUid::Uid( *(iPropertyValues[EUid]) ); |
448 TUid aUid = TUid::Uid( *(iPropertyValues[EUid]) ); |
481 iWidgetInHS = iRegistry.IsWidgetInMiniView( aUid ); |
449 iWidgetInHS = iRegistry.IsWidgetInMiniView( aUid ); |
|
450 if ( iRegistry.IsWidgetRunning( aUid ) ) |
|
451 { |
|
452 //Runnning widget should be first closed |
|
453 RApaLsSession apaLsSession; |
|
454 apaLsSession.Connect(); |
|
455 TApaAppInfo info; |
|
456 |
|
457 User::LeaveIfError( apaLsSession.GetAppInfo( info, aUid ) ); |
|
458 iWidgetName = info.iFullName; |
|
459 HBufC *widgetName = iWidgetName.AllocLC(); |
|
460 HandleWidgetCommandL(apaLsSession, *widgetName, aUid, Deactivate); |
|
461 |
|
462 CleanupStack::PopAndDestroy( widgetName ); |
|
463 apaLsSession.Close(); |
|
464 } |
482 // get original install dir from registry in case user |
465 // get original install dir from registry in case user |
483 // decides to "overrite" to another memory location |
466 // decides to "overrite" to another memory location |
484 CWidgetPropertyValue *propValue = iRegistry.GetWidgetPropertyValueL( |
467 iOriginalDir = *( iRegistry.GetWidgetPropertyValueL( |
485 TUid::Uid( *(iPropertyValues[EUid]) ), |
468 TUid::Uid( *(iPropertyValues[EUid]) ), |
486 EBasePath ); |
469 EBasePath ) ); |
487 |
|
488 iOriginalDir.Zero(); |
|
489 if(propValue) |
|
490 iOriginalDir = *propValue; |
|
491 |
|
492 delete propValue; |
|
493 } |
470 } |
494 // uid for a new widget will be gotten once install location (c: or |
471 // uid for a new widget will be gotten once install location (c: or |
495 // e:) is selected |
472 // e:) is selected |
496 |
473 |
497 // see if main.html is in zip bundle |
474 // see if main.html is in zip bundle |
774 if ( !iCancelled ) |
751 if ( !iCancelled ) |
775 { |
752 { |
776 if ( iOverwriting ) |
753 if ( iOverwriting ) |
777 { |
754 { |
778 TUid uid = TUid::Uid( *(iPropertyValues[EUid]) ); |
755 TUid uid = TUid::Uid( *(iPropertyValues[EUid]) ); |
|
756 iRegistry.DeRegisterWidgetL( uid ); |
779 iAppManager->DeregisterWidgetL( uid ); |
757 iAppManager->DeregisterWidgetL( uid ); |
780 iRegistry.DeRegisterWidgetL( uid ); |
|
781 } |
758 } |
782 |
759 |
783 // TODO if registration steps fail does it leave inconsistent state??? |
760 // TODO if registration steps fail does it leave inconsistent state??? |
784 |
761 |
|
762 iRegistry.RegisterWidgetL( iPropertyValues ); |
785 |
763 |
786 iAppManager->RegisterWidgetL( *(iPropertyValues[EMainHTML]), |
764 iAppManager->RegisterWidgetL( *(iPropertyValues[EMainHTML]), |
787 *(iPropertyValues[EBundleDisplayName]), |
765 *(iPropertyValues[EBundleDisplayName]), |
788 *(iPropertyValues[EIconPath]), |
766 *(iPropertyValues[EIconPath]), |
789 *(iPropertyValues[EDriveName]), |
767 *(iPropertyValues[EDriveName]), |
790 TUid::Uid( *(iPropertyValues[EUid]) ) ); |
768 TUid::Uid( *(iPropertyValues[EUid]) ) ); |
791 |
769 |
792 iRegistry.RegisterWidgetL( iPropertyValues ); |
|
793 |
|
794 |
|
795 |
|
796 if ( iOverwriting ) |
770 if ( iOverwriting ) |
797 { |
771 { |
798 // delete backup |
772 // delete backup |
799 (void)iFileMgr->RmDir( iBackupDir ); |
773 (void)iFileMgr->RmDir( iBackupDir ); |
|
774 if ( iWidgetInHS ) |
|
775 { |
|
776 RApaLsSession apaLsSession; |
|
777 apaLsSession.Connect(); |
|
778 |
|
779 HBufC* widgetName = iWidgetName.AllocLC(); |
|
780 HandleWidgetCommandL(apaLsSession, *widgetName, TUid::Uid( *(iPropertyValues[EUid]) ), WidgetRestart); |
|
781 CleanupStack::PopAndDestroy( widgetName ); |
|
782 |
|
783 apaLsSession.Close(); |
|
784 } |
800 } |
785 } |
801 if ( !iSilent ) |
786 if ( !iSilent ) |
802 { |
787 { |
803 iUIHandler->CloseFinalizeDialogL(); |
788 iUIHandler->CloseFinalizeDialogL(); |
804 iUIHandler->DisplayCompleteL(); |
789 iUIHandler->DisplayCompleteL(); |
805 } |
790 } |
806 |
791 |
807 HandleLogsL(*(iPropertyValues[EBundleDisplayName]), TUid::Uid( *(iPropertyValues[EUid]) ), *(iPropertyValues[ENokiaWidget]), *(iPropertyValues[EBundleVersion]), SwiUI::ELogTaskActionInstall); |
792 HandleLogsL(*(iPropertyValues[EBundleDisplayName]), TUid::Uid( *(iPropertyValues[EUid]) ), *(iPropertyValues[ENokiaWidget]), SwiUI::ELogTaskActionInstall); |
808 } |
793 } |
809 else // cancelled |
794 else // cancelled |
810 { |
795 { |
811 // delete what was being installed, and restore previous |
796 // delete what was being installed, and restore previous |
812 (void)iFileMgr->RmDir( *(iPropertyValues[EBasePath]) ); |
797 (void)iFileMgr->RmDir( *(iPropertyValues[EBasePath]) ); |
1003 apaLsSession.Close(); |
988 apaLsSession.Close(); |
1004 } |
989 } |
1005 if ( !iSilent ) { iUIHandler->DisplayUninstallInProgressL(); } |
990 if ( !iSilent ) { iUIHandler->DisplayUninstallInProgressL(); } |
1006 TBuf<KWidgetRegistryVal> widgetPath; |
991 TBuf<KWidgetRegistryVal> widgetPath; |
1007 iRegistry.GetWidgetPath( aUid, widgetPath ); |
992 iRegistry.GetWidgetPath( aUid, widgetPath ); |
1008 |
993 TBool aVendor = *(iRegistry.GetWidgetPropertyValueL(aUid, ENokiaWidget)); |
1009 CWidgetPropertyValue* propValue = iRegistry.GetWidgetPropertyValueL(aUid, ENokiaWidget); |
994 |
1010 TBool aVendor = propValue && *(propValue); |
|
1011 delete propValue; |
|
1012 propValue = NULL; |
|
1013 propValue = iRegistry.GetWidgetPropertyValueL(aUid,EBundleVersion); |
|
1014 TBuf<KWidgetRegistryVal> version; |
|
1015 if(propValue) |
|
1016 version = (const TDesC& )*propValue; |
|
1017 delete propValue; |
|
1018 |
995 |
1019 // TODO if any of next steps leave does state become inconsistent? |
996 // TODO if any of next steps leave does state become inconsistent? |
1020 |
997 |
1021 // remove the dir for the widget |
998 // remove the dir for the widget |
1022 // TODO why this validation? |
999 // TODO why this validation? |
1034 ptr.Insert(pos+1,buf1); |
1011 ptr.Insert(pos+1,buf1); |
1035 iRfs.Delete(ptr); |
1012 iRfs.Delete(ptr); |
1036 CleanupStack::PopAndDestroy(fileName); |
1013 CleanupStack::PopAndDestroy(fileName); |
1037 } |
1014 } |
1038 |
1015 |
|
1016 iRegistry.DeRegisterWidgetL( aUid ); |
1039 iAppManager->DeregisterWidgetL( aUid ); |
1017 iAppManager->DeregisterWidgetL( aUid ); |
1040 iRegistry.DeRegisterWidgetL( aUid ); |
|
1041 TInt err = KErrNone; |
1018 TInt err = KErrNone; |
1042 TRAP(err, FinishUninstallL( KErrNone )); |
1019 TRAP(err, FinishUninstallL( KErrNone )); |
1043 if(err == KErrNone) |
1020 if(err == KErrNone) |
1044 { |
1021 { |
1045 HandleLogsL(bundleName, aUid, aVendor, version, SwiUI::ELogTaskActionUninstall); |
1022 HandleLogsL(bundleName, aUid, aVendor, SwiUI::ELogTaskActionUninstall); |
1046 } |
1023 } |
1047 } |
1024 } |
1048 else |
1025 else |
1049 { |
1026 { |
1050 if ( !iSilent ) { iUIHandler->DisplayCancelL(); } |
1027 if ( !iSilent ) { iUIHandler->DisplayCancelL(); } |
1329 // ============================================================================ |
1306 // ============================================================================ |
1330 // |
1307 // |
1331 // CWidgetUIOperationsWatcher::HandleLogsL |
1308 // CWidgetUIOperationsWatcher::HandleLogsL |
1332 // |
1309 // |
1333 // ============================================================================ |
1310 // ============================================================================ |
1334 void CWidgetUIOperationsWatcher::HandleLogsL(const TDesC& aWidgetName, const TUid &aUid, TBool aVender, const TDesC& aVersion, SwiUI::TLogTaskAction aAction) |
1311 void CWidgetUIOperationsWatcher::HandleLogsL(const TDesC& aWidgetName, const TUid &aUid, TBool aVender, SwiUI::TLogTaskAction aAction) |
1335 { |
1312 { |
1336 CTask* task = CTask::NewL( KLogTaskImplUid, EFalse ); |
1313 CTask* task = CTask::NewL( KLogTaskImplUid, EFalse ); |
1337 CleanupStack::PushL(task); |
1314 CleanupStack::PushL(task); |
1338 |
1315 |
1339 TLogTaskParam params; |
1316 TLogTaskParam params; |
1343 params.iVendor.Copy((aVender ? _L("Nokia") : _L("Non-Nokia"))); |
1320 params.iVendor.Copy((aVender ? _L("Nokia") : _L("Non-Nokia"))); |
1344 |
1321 |
1345 TTime time; |
1322 TTime time; |
1346 time.UniversalTime(); |
1323 time.UniversalTime(); |
1347 params.iTime = time; |
1324 params.iTime = time; |
1348 |
1325 |
1349 TLex lex(aVersion); |
|
1350 TInt i[] = {0,0,0}, j = 0; |
|
1351 while((lex.Get()) != 0 ) |
|
1352 { |
|
1353 TInt num = 0; |
|
1354 while ( lex.Peek() && (lex.Peek()) != '.') |
|
1355 lex.Inc(); |
|
1356 TLex toNum(lex.MarkedToken()); |
|
1357 toNum.Val(num); |
|
1358 i[j++] = num; |
|
1359 lex.Inc(); |
|
1360 lex.Mark(); |
|
1361 } |
|
1362 params.iVersion.iMajor = i[0]; |
|
1363 params.iVersion.iMinor = i[1]; |
|
1364 params.iVersion.iBuild = i[2]; |
|
1365 |
|
1366 TLogTaskParamPckg pckg( params ); |
1326 TLogTaskParamPckg pckg( params ); |
1367 task->SetParameterL( pckg, 0 ); |
1327 task->SetParameterL( pckg, 0 ); |
1368 iTaskManager->AddTaskL( task ); |
1328 iTaskManager->AddTaskL( task ); |
1369 iTaskManager->CommitL(); |
1329 iTaskManager->CommitL(); |
1370 |
1330 |