233 // widget file with no icon. Why, I'm not sure but probably |
234 // widget file with no icon. Why, I'm not sure but probably |
234 // had to do with this active object blocking display |
235 // had to do with this active object blocking display |
235 // processing. So here is a good place to put up the displays |
236 // processing. So here is a good place to put up the displays |
236 // (before RunL() is invoked) which lets other objects run. |
237 // (before RunL() is invoked) which lets other objects run. |
237 |
238 |
238 iUIHandler->DisplayFinalizeDialogL(); // a dialog without a cancel option |
239 if ( !iSilent ) |
239 iUIHandler->DisplayProgressDialogL(); // progress bar |
240 { |
|
241 iUIHandler->DisplayFinalizeDialogL(); // a dialog without a cancel option |
|
242 iUIHandler->DisplayProgressDialogL(); // progress bar |
|
243 } |
240 |
244 |
241 if ( replaceExisting ) |
245 if ( replaceExisting ) |
242 { |
246 { |
243 BackupL(); // nothing need be undone if backup leaves |
247 BackupL(); // nothing need be undone if backup leaves |
244 // backup will gaurantee that install dir is empty |
248 // backup will gaurantee that install dir is empty |
445 { |
451 { |
446 //Runnning widget should be first closed |
452 //Runnning widget should be first closed |
447 RApaLsSession apaLsSession; |
453 RApaLsSession apaLsSession; |
448 apaLsSession.Connect(); |
454 apaLsSession.Connect(); |
449 TApaAppInfo info; |
455 TApaAppInfo info; |
450 |
456 |
451 User::LeaveIfError( apaLsSession.GetAppInfo( info, aUid ) ); |
457 User::LeaveIfError( apaLsSession.GetAppInfo( info, aUid ) ); |
452 iWidgetName = info.iFullName; |
458 iWidgetName = info.iFullName; |
453 HBufC *widgetName = iWidgetName.AllocLC(); |
459 HBufC *widgetName = iWidgetName.AllocLC(); |
454 HandleWidgetCommandL(apaLsSession, *widgetName, aUid, Deactivate); |
460 HandleWidgetCommandL(apaLsSession, *widgetName, aUid, Deactivate); |
455 |
461 |
456 CleanupStack::PopAndDestroy( widgetName ); |
462 CleanupStack::PopAndDestroy( widgetName ); |
457 apaLsSession.Close(); |
463 apaLsSession.Close(); |
458 } |
464 } |
459 // get original install dir from registry in case user |
465 // get original install dir from registry in case user |
460 // decides to "overrite" to another memory location |
466 // decides to "overrite" to another memory location |
756 |
769 |
757 if ( iOverwriting ) |
770 if ( iOverwriting ) |
758 { |
771 { |
759 // delete backup |
772 // delete backup |
760 (void)iFileMgr->RmDir( iBackupDir ); |
773 (void)iFileMgr->RmDir( iBackupDir ); |
761 |
|
762 // if widget was in home screen, add it back to home screen |
|
763 if ( iWidgetInHS ) |
774 if ( iWidgetInHS ) |
764 { |
775 { |
765 RApaLsSession apaLsSession; |
776 RApaLsSession apaLsSession; |
766 apaLsSession.Connect(); |
777 apaLsSession.Connect(); |
767 |
778 |
768 HBufC* widgetName = iWidgetName.AllocLC(); |
779 HBufC* widgetName = iWidgetName.AllocLC(); |
769 HandleWidgetCommandL(apaLsSession, *widgetName, TUid::Uid( *(iPropertyValues[EUid]) ), WidgetRestart); |
780 HandleWidgetCommandL(apaLsSession, *widgetName, TUid::Uid( *(iPropertyValues[EUid]) ), WidgetRestart); |
770 CleanupStack::PopAndDestroy( widgetName ); |
781 CleanupStack::PopAndDestroy( widgetName ); |
771 |
782 |
772 apaLsSession.Close(); |
783 apaLsSession.Close(); |
773 } |
784 } |
774 } |
785 } |
775 |
786 if ( !iSilent ) |
776 iUIHandler->CloseFinalizeDialogL(); |
787 { |
777 iUIHandler->DisplayCompleteL(); |
788 iUIHandler->CloseFinalizeDialogL(); |
|
789 iUIHandler->DisplayCompleteL(); |
|
790 } |
778 |
791 |
779 HandleLogsL(*(iPropertyValues[EBundleDisplayName]), TUid::Uid( *(iPropertyValues[EUid]) ), *(iPropertyValues[ENokiaWidget]), SwiUI::ELogTaskActionInstall); |
792 HandleLogsL(*(iPropertyValues[EBundleDisplayName]), TUid::Uid( *(iPropertyValues[EUid]) ), *(iPropertyValues[ENokiaWidget]), SwiUI::ELogTaskActionInstall); |
780 } |
793 } |
781 else // cancelled |
794 else // cancelled |
782 { |
795 { |
931 iUIHandler = |
950 iUIHandler = |
932 CWidgetUIHandler::NewL( CWidgetUIHandler::EModeUninstall, this ); |
951 CWidgetUIHandler::NewL( CWidgetUIHandler::EModeUninstall, this ); |
933 |
952 |
934 // save client status to use in finish uninstall |
953 // save client status to use in finish uninstall |
935 iRequestStatus = &aRequestStatus; |
954 iRequestStatus = &aRequestStatus; |
936 |
955 |
937 TBuf<KWidgetRegistryVal> bundleName; |
956 TBuf<KWidgetRegistryVal> bundleName; |
938 iRegistry.GetWidgetBundleName( aUid, bundleName ); |
957 iRegistry.GetWidgetBundleName( aUid, bundleName ); |
939 |
958 |
940 if( bundleName.Length() <= 0 ) |
959 if( bundleName.Length() <= 0 ) |
941 { |
960 { |
942 FinishUninstallL( KErrCorrupt ); |
961 FinishUninstallL( KErrCorrupt ); |
943 return; |
962 return; |
944 } |
963 } |
945 |
964 |
946 TBool widgetinHomeScreen(EFalse); |
965 TBool widgetinHomeScreen(EFalse); |
947 widgetinHomeScreen = iRegistry.IsWidgetInMiniView( aUid ); |
966 widgetinHomeScreen = iRegistry.IsWidgetInMiniView( aUid ); |
|
967 |
|
968 TBool uninstall( ETrue ); |
|
969 if ( !iSilent ) |
|
970 { |
|
971 uninstall = iUIHandler->DisplayUninstallL( bundleName,widgetinHomeScreen ); |
|
972 } |
948 // prompt user to uninstall |
973 // prompt user to uninstall |
949 if( iUIHandler->DisplayUninstallL( bundleName,widgetinHomeScreen ) ) |
974 if( uninstall ) |
950 { |
975 { |
951 if(iRegistry.IsWidgetRunning( aUid )) |
976 if(iRegistry.IsWidgetRunning( aUid )) |
952 //Runnning widget should be first closed |
977 //Runnning widget should be first closed |
953 { |
978 { |
954 RApaLsSession apaLsSession; |
979 RApaLsSession apaLsSession; |
955 apaLsSession.Connect(); |
980 apaLsSession.Connect(); |
956 TApaAppInfo info; |
981 TApaAppInfo info; |
957 |
982 |
958 User::LeaveIfError( apaLsSession.GetAppInfo( info, aUid ) ); |
983 User::LeaveIfError( apaLsSession.GetAppInfo( info, aUid ) ); |
959 HBufC* widgetName = info.iFullName.AllocLC(); |
984 HBufC* widgetName = info.iFullName.AllocLC(); |
960 HandleWidgetCommandL(apaLsSession,*widgetName,aUid,Deactivate); |
985 HandleWidgetCommandL(apaLsSession,*widgetName,aUid,Deactivate); |
961 |
986 |
962 CleanupStack::PopAndDestroy( widgetName ); |
987 CleanupStack::PopAndDestroy( widgetName ); |
963 apaLsSession.Close(); |
988 apaLsSession.Close(); |
964 } |
989 } |
965 iUIHandler->DisplayUninstallInProgressL(); |
990 if ( !iSilent ) { iUIHandler->DisplayUninstallInProgressL(); } |
966 TBuf<KWidgetRegistryVal> widgetPath; |
991 TBuf<KWidgetRegistryVal> widgetPath; |
967 iRegistry.GetWidgetPath( aUid, widgetPath ); |
992 iRegistry.GetWidgetPath( aUid, widgetPath ); |
968 TBool aVendor = *(iRegistry.GetWidgetPropertyValueL(aUid, ENokiaWidget)); |
993 TBool aVendor = *(iRegistry.GetWidgetPropertyValueL(aUid, ENokiaWidget)); |
969 |
994 |
970 |
995 |
971 // TODO if any of next steps leave does state become inconsistent? |
996 // TODO if any of next steps leave does state become inconsistent? |
972 |
997 |
973 // remove the dir for the widget |
998 // remove the dir for the widget |
974 // TODO why this validation? |
999 // TODO why this validation? |
975 if ( widgetPath.Length() > 0 ) |
1000 if ( widgetPath.Length() > 0 ) |
976 { |
1001 { |
977 iFileMgr->RmDir( widgetPath ); |
1002 iFileMgr->RmDir( widgetPath ); |
978 //Widget should delete any cookie it created |
1003 //Widget should delete any cookie it created |
979 HBufC* fileName = HBufC::NewLC(KMaxFileName); |
1004 HBufC* fileName = HBufC::NewLC(KMaxFileName); |
980 TPtr ptr(fileName->Des()); |
1005 TPtr ptr(fileName->Des()); |
981 TBuf<8> buf1; |
1006 TBuf<8> buf1; |
982 ptr = KCookieFile; |
1007 ptr = KCookieFile; |
983 TInt pos = ptr.LocateReverse('.'); |
1008 TInt pos = ptr.LocateReverse('.'); |
984 buf1.AppendNum(aUid.iUid,EHex); |
1009 buf1.AppendNum(aUid.iUid,EHex); |
985 ptr.Insert(pos,_L("_")); |
1010 ptr.Insert(pos,_L("_")); |
986 ptr.Insert(pos+1,buf1); |
1011 ptr.Insert(pos+1,buf1); |
987 iRfs.Delete(ptr); |
1012 iRfs.Delete(ptr); |
988 CleanupStack::PopAndDestroy(fileName); |
1013 CleanupStack::PopAndDestroy(fileName); |
1014 // @since 3.1 |
1039 // @since 3.1 |
1015 // ============================================================================ |
1040 // ============================================================================ |
1016 // |
1041 // |
1017 void CWidgetUIOperationsWatcher::FinishUninstallL( TInt aErr ) |
1042 void CWidgetUIOperationsWatcher::FinishUninstallL( TInt aErr ) |
1018 { |
1043 { |
1019 iUIHandler->CloseUninstallInProgressDialogL(); |
1044 if ( !iSilent ) { iUIHandler->CloseUninstallInProgressDialogL(); } |
1020 if ( aErr ) |
1045 if ( aErr ) |
1021 { |
1046 { |
1022 iUIHandler->DisplayErrorL( aErr ); |
1047 if ( !iSilent ) { iUIHandler->DisplayErrorL( aErr ); } |
1023 User::Leave( aErr ); |
1048 User::Leave( aErr ); |
1024 } |
1049 } |
1025 iUIHandler->DisplayCompleteL(); |
1050 if ( !iSilent ) { iUIHandler->DisplayCompleteL(); } |
1026 User::RequestComplete( iRequestStatus, KErrNone ); |
1051 User::RequestComplete( iRequestStatus, KErrNone ); |
1027 iRequestStatus = NULL; |
1052 iRequestStatus = NULL; |
1028 } |
1053 } |
1029 |
1054 |
1030 // ============================================================================ |
1055 // ============================================================================ |
1162 // @since 3.1 |
1187 // @since 3.1 |
1163 // ============================================================================ |
1188 // ============================================================================ |
1164 // |
1189 // |
1165 TBool CWidgetUIOperationsWatcher::PromptUserForInstallL( TBool aOverwrite ) |
1190 TBool CWidgetUIOperationsWatcher::PromptUserForInstallL( TBool aOverwrite ) |
1166 { |
1191 { |
1167 TBool userAnswer; |
1192 TBool userAnswer( ETrue ); |
1168 |
1193 |
1169 if ( aOverwrite ) |
1194 if ( !iSilent ) |
1170 { |
1195 { |
1171 userAnswer = |
1196 if ( aOverwrite ) |
1172 iUIHandler->DisplayOverwriteL( *(iPropertyValues[EBundleDisplayName]) ); |
1197 { |
|
1198 userAnswer = |
|
1199 iUIHandler->DisplayOverwriteL( *(iPropertyValues[EBundleDisplayName]) ); |
|
1200 } |
|
1201 else |
|
1202 { |
|
1203 userAnswer = |
|
1204 iUIHandler->DisplayInstallL( *(iPropertyValues[EBundleDisplayName]) ); |
|
1205 } |
|
1206 if ( userAnswer ) |
|
1207 { |
|
1208 userAnswer = SelectMemoryL(); |
|
1209 } |
1173 } |
1210 } |
1174 else |
1211 else |
1175 { |
1212 { |
1176 userAnswer = |
1213 TDriveUnit selectedDrive(_L("C")); // in real should be read from install options which are ignore too at the moment. |
1177 iUIHandler->DisplayInstallL( *(iPropertyValues[EBundleDisplayName]) ); |
1214 UpdateWidgetBasePathL( selectedDrive ); |
1178 } |
1215 *(iPropertyValues[EDriveName]) = selectedDrive.Name(); |
1179 if ( userAnswer ) |
1216 } |
1180 { |
1217 |
1181 userAnswer = SelectMemoryL(); |
|
1182 } |
|
1183 return userAnswer; |
1218 return userAnswer; |
1184 } |
1219 } |
1185 |
1220 |
1186 // ============================================================================ |
1221 // ============================================================================ |
1187 // CWidgetUIOperationsWatcher::PromptUserForUntrustedWidgetL() |
1222 // CWidgetUIOperationsWatcher::PromptUserForUntrustedWidgetL() |
1281 TLogTaskParam params; |
1316 TLogTaskParam params; |
1282 params.iName.Copy(aWidgetName); |
1317 params.iName.Copy(aWidgetName); |
1283 params.iUid = aUid; |
1318 params.iUid = aUid; |
1284 params.iAction = aAction; |
1319 params.iAction = aAction; |
1285 params.iVendor.Copy((aVender ? _L("Nokia") : _L("Non-Nokia"))); |
1320 params.iVendor.Copy((aVender ? _L("Nokia") : _L("Non-Nokia"))); |
1286 |
1321 |
1287 TTime time; |
1322 TTime time; |
1288 time.UniversalTime(); |
1323 time.UniversalTime(); |
1289 params.iTime = time; |
1324 params.iTime = time; |
1290 |
1325 |
1291 TLogTaskParamPckg pckg( params ); |
1326 TLogTaskParamPckg pckg( params ); |
1292 task->SetParameterL( pckg, 0 ); |
1327 task->SetParameterL( pckg, 0 ); |
1293 iTaskManager->AddTaskL( task ); |
1328 iTaskManager->AddTaskL( task ); |
1294 iTaskManager->CommitL(); |
1329 iTaskManager->CommitL(); |
1295 |
1330 |
1296 CleanupStack::Pop(task); |
1331 CleanupStack::Pop(task); |
1297 } |
1332 } |
1298 |
1333 |
1299 // ============================================================================ |
1334 // ============================================================================ |
1300 // |
1335 // |
1302 // |
1337 // |
1303 // ============================================================================ |
1338 // ============================================================================ |
1304 void CWidgetUIOperationsWatcher::HandleWidgetCommandL( RApaLsSession& aSession,const TDesC& aWidget,const TUid& aUid,TUint32 aOperation ) |
1339 void CWidgetUIOperationsWatcher::HandleWidgetCommandL( RApaLsSession& aSession,const TDesC& aWidget,const TUid& aUid,TUint32 aOperation ) |
1305 { |
1340 { |
1306 const TInt size( 2* aWidget.Length() + 3*sizeof( TUint32 ) ); |
1341 const TInt size( 2* aWidget.Length() + 3*sizeof( TUint32 ) ); |
1307 |
1342 |
1308 // Message format is <filenameLength><unicode_filename><someintegervalue> |
1343 // Message format is <filenameLength><unicode_filename><someintegervalue> |
1309 CApaCommandLine* cmd( CApaCommandLine::NewLC() ); |
1344 CApaCommandLine* cmd( CApaCommandLine::NewLC() ); |
1310 HBufC8* opaque( HBufC8::NewLC( size ) ); |
1345 HBufC8* opaque( HBufC8::NewLC( size ) ); |
1311 |
1346 |
1312 RDesWriteStream stream; |
1347 RDesWriteStream stream; |
1313 TPtr8 des( opaque->Des() ); |
1348 TPtr8 des( opaque->Des() ); |
1314 |
1349 |
1315 stream.Open( des ); |
1350 stream.Open( des ); |
1316 CleanupClosePushL( stream ); |
1351 CleanupClosePushL( stream ); |
1317 |
1352 |
1318 // Generate the command. |
1353 // Generate the command. |
1319 stream.WriteUint32L( aUid.iUid ); |
1354 stream.WriteUint32L( aUid.iUid ); |
1320 stream.WriteUint32L( aWidget.Length() ); |
1355 stream.WriteUint32L( aWidget.Length() ); |
1321 stream.WriteL( reinterpret_cast< const TUint8* >( aWidget.Ptr() ), |
1356 stream.WriteL( reinterpret_cast< const TUint8* >( aWidget.Ptr() ), |
1322 aWidget.Size() ); |
1357 aWidget.Size() ); |
1323 |
1358 |
1324 stream.WriteInt32L( aOperation ); |
1359 stream.WriteInt32L( aOperation ); |
1325 |
1360 |
1326 CleanupStack::PopAndDestroy( &stream ); |
1361 CleanupStack::PopAndDestroy( &stream ); |
1327 |
1362 |
1328 // Generate command. |
1363 // Generate command. |
1329 cmd->SetCommandL( EApaCommandBackgroundAndWithoutViews ); |
1364 cmd->SetCommandL( EApaCommandBackgroundAndWithoutViews ); |
1330 cmd->SetOpaqueDataL( *opaque ); |
1365 cmd->SetOpaqueDataL( *opaque ); |
1331 |
1366 |
1332 CleanupStack::PopAndDestroy( opaque ); |
1367 CleanupStack::PopAndDestroy( opaque ); |
1333 |
1368 |
1334 cmd->SetExecutableNameL( KLauncherApp ); |
1369 cmd->SetExecutableNameL( KLauncherApp ); |
1335 |
1370 |
1336 User::LeaveIfError( aSession.StartApp( *cmd ) ); |
1371 User::LeaveIfError( aSession.StartApp( *cmd ) ); |
1337 CleanupStack::PopAndDestroy( cmd ); |
1372 CleanupStack::PopAndDestroy( cmd ); |
1338 } |
1373 } |
1339 // End of File |
1374 // End of File |