1108 // --------------------------------------------------------------------------- |
1110 // --------------------------------------------------------------------------- |
1109 // |
1111 // |
1110 // --------------------------------------------------------------------------- |
1112 // --------------------------------------------------------------------------- |
1111 // |
1113 // |
1112 TBool CHnEngine::HandleActionL( const TDesC8& aUri ) |
1114 TBool CHnEngine::HandleActionL( const TDesC8& aUri ) |
1113 { |
1115 { |
1114 TBool exitActionConsumed(EFalse); |
1116 TBool exitActionConsumed( EFalse ); |
1115 |
1117 |
1116 HBufC8* uriBuf = HBufC8::NewLC( aUri.Length() ); |
1118 HBufC8* uriBuf = HBufC8::NewLC( aUri.Length() ); |
1117 uriBuf->Des().Copy( aUri ); |
1119 uriBuf->Des().Copy( aUri ); |
1118 |
1120 |
1119 TUriParser8 parser; |
1121 TUriParser8 parser; |
1120 parser.Parse( *uriBuf ); |
1122 parser.Parse( *uriBuf ); |
1121 User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound ); |
1123 User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound ); |
1122 |
1124 |
1123 const TDesC8& host8 = parser.Extract( EUriHost ); |
1125 const TDesC8& host8 = parser.Extract( EUriHost ); |
1124 const TDesC8& query = parser.Extract( EUriQuery ); |
1126 const TDesC8& query = parser.Extract( EUriQuery ); |
1125 |
1127 |
1126 RBuf action; |
1128 RBuf action; |
1127 CleanupClosePushL( action ); |
1129 CleanupClosePushL( action ); |
1128 CLiwGenericParamList* paramsUri = UriQueryToLiwListLC( query, KNullDesC8, KNullDesC8 ); |
1130 CLiwGenericParamList* paramsUri = UriQueryToLiwListLC( query, KNullDesC8, KNullDesC8 ); |
1129 HnLiwUtils::GetStringL( *paramsUri, KActionParams, action ); |
1131 HnLiwUtils::GetStringL( *paramsUri, KActionParams, action ); |
1130 |
1132 |
1131 if ( !action.Compare( KActionExit ) ) |
1133 if( !action.Compare( KActionExit ) ) |
1132 { |
1134 { |
1133 RBuf host; |
1135 RBuf host; |
1134 host.CreateL( host8.Length() ); |
1136 host.CreateL( host8.Length() ); |
1135 CleanupClosePushL( host ); |
1137 CleanupClosePushL( host ); |
1136 host.Copy(host8); |
1138 host.Copy( host8 ); |
1137 CHnSuiteModel* suiteModel = iSuiteContainer->GetSuiteModel( host ); |
1139 CHnSuiteModel* suiteModel = iSuiteContainer->GetSuiteModel( host ); |
1138 TBool exitHideHostNotFound( ETrue ); |
1140 TBool exitHideHostNotFound( ETrue ); |
1139 if( suiteModel && suiteModel->ExitMode() == EExitModeHide ) |
1141 if( suiteModel && suiteModel->ExitMode() == EExitModeHide ) |
1140 { |
1142 { |
1141 exitHideHostNotFound = EFalse; |
1143 exitHideHostNotFound = EFalse; |
1142 } |
1144 } |
1143 |
1145 |
1144 if ( exitHideHostNotFound ) |
1146 if( exitHideHostNotFound ) |
1145 { |
1147 { |
1146 //send to foreground |
1148 //send to foreground |
1147 CLiwGenericParamList* pl = CLiwGenericParamList::NewL(); |
1149 CLiwGenericParamList* pl = CLiwGenericParamList::NewL(); |
1148 CleanupStack::PushL( pl ); |
1150 CleanupStack::PushL( pl ); |
1149 HandleModelEventL( KAppGainForeground, *pl ); |
1151 HandleModelEventL( KAppGainForeground, *pl ); |
1150 CleanupStack::PopAndDestroy( pl ); |
1152 CleanupStack::PopAndDestroy( pl ); |
1151 } |
1153 } |
1152 else |
1154 else |
1153 { |
1155 { |
1154 //send to background |
1156 //send to background |
1155 CLiwGenericParamList* pl = CLiwGenericParamList::NewL(); |
1157 CLiwGenericParamList* pl = CLiwGenericParamList::NewL(); |
1156 CleanupStack::PushL( pl ); |
1158 CleanupStack::PushL( pl ); |
1157 HandleModelEventL( KAppGainBackground, *pl ); |
1159 HandleModelEventL( KAppGainBackground, *pl ); |
1158 CleanupStack::PopAndDestroy( pl ); |
1160 CleanupStack::PopAndDestroy( pl ); |
1159 } |
1161 } |
1160 |
1162 |
1161 if ( exitHideHostNotFound && iSuiteContainer->GetLastSuiteModel() == suiteModel ) |
1163 if( exitHideHostNotFound && iSuiteContainer->GetLastSuiteModel() == suiteModel ) |
1162 { |
1164 { |
1163 HandleBackEventL( host, 1 ); |
1165 HandleBackEventL( host, 1 ); |
1164 } |
1166 } |
1165 else |
1167 else |
1166 { |
1168 { |
1167 //reset to root |
1169 //reset to root |
1168 CLiwGenericParamList* params = CLiwGenericParamList::NewLC(); |
1170 CLiwGenericParamList* params = CLiwGenericParamList::NewLC(); |
1169 params->AppendL( iMetaDataModel->GetSuiteParameters( 0 ) ); |
1171 params->AppendL( iMetaDataModel->GetSuiteParameters( 0 ) ); |
1170 ResetModelsL(); |
1172 ResetModelsL(); |
1171 InitializeL( *params ); |
1173 InitializeL( *params ); |
1172 CleanupStack::PopAndDestroy( params ); |
1174 CleanupStack::PopAndDestroy( params ); |
1173 } |
1175 } |
1174 |
1176 |
1175 CleanupStack::PopAndDestroy( &host ); |
1177 CleanupStack::PopAndDestroy( &host ); |
1176 exitActionConsumed = ETrue; |
1178 exitActionConsumed = ETrue; |
1177 } |
1179 } |
1178 |
1180 |
1179 CleanupStack::PopAndDestroy( paramsUri ); |
1181 CleanupStack::PopAndDestroy( paramsUri ); |
1180 CleanupStack::PopAndDestroy( &action ); |
1182 CleanupStack::PopAndDestroy( &action ); |
1181 CleanupStack::PopAndDestroy( uriBuf ); |
1183 CleanupStack::PopAndDestroy( uriBuf ); |
1182 return exitActionConsumed; |
1184 return exitActionConsumed; |
1183 } |
1185 } |
1184 |
1186 |
1185 // --------------------------------------------------------------------------- |
1187 // --------------------------------------------------------------------------- |
1186 // |
1188 // |
1187 // --------------------------------------------------------------------------- |
1189 // --------------------------------------------------------------------------- |
1188 // |
1190 // |
1189 void CHnEngine::LoadSuitesL( const TDesC8& aUri ) |
1191 void CHnEngine::LoadSuitesL( const TDesC8& aUri ) |
1190 { |
1192 { |
1191 TBool sendToForeground(EFalse); |
1193 TBool sendToForeground(EFalse); |
1192 HBufC8* uriBuf = HBufC8::NewLC( aUri.Length() ); |
1194 HBufC8* uriBuf = HBufC8::NewLC( aUri.Length() ); |
1193 uriBuf->Des().Copy( aUri ); |
1195 uriBuf->Des().Copy( aUri ); |
1194 |
1196 |
1195 TUriParser8 parser; |
1197 TUriParser8 parser; |
1196 parser.Parse( *uriBuf ); |
1198 parser.Parse( *uriBuf ); |
1197 User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound ); |
1199 User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound ); |
1198 |
1200 |
1199 CDesC8ArrayFlat* suiteNameArray = new( ELeave ) CDesC8ArrayFlat( KDefaultGranularity ) ; |
1201 CDesC8ArrayFlat* suiteNameArray = new( ELeave ) CDesC8ArrayFlat( KDefaultGranularity ) ; |
1200 CleanupStack::PushL( suiteNameArray ); |
1202 CleanupStack::PushL( suiteNameArray ); |
1201 |
1203 |
1202 const TDesC8& host = parser.Extract( EUriHost ); |
1204 const TDesC8& host = parser.Extract( EUriHost ); |
1203 RBuf8 host8; |
1205 RBuf8 host8; |
1204 CleanupClosePushL( host8 ); |
1206 CleanupClosePushL( host8 ); |
1205 if (host.Compare( KNullDesC8 )) |
1207 if (host.Compare( KNullDesC8 )) |
1206 { |
1208 { |
1207 host8.CreateL( host ); |
1209 host8.CreateL( host ); |
1208 host8.LowerCase(); |
1210 host8.LowerCase(); |
1209 suiteNameArray->AppendL( host8 ); |
1211 suiteNameArray->AppendL( host8 ); |
1210 DEBUG8(( "_MM_:\tURI host part: %S", &host8 )); |
1212 DEBUG8(( "_MM_:\tURI host part: %S", &host8 )); |
1211 } |
1213 } |
1212 |
1214 |
1213 const TDesC8& path = parser.Extract( EUriPath ); |
1215 const TDesC8& path = parser.Extract( EUriPath ); |
1214 if (path.Compare( KNullDesC8 )) |
1216 if (path.Compare( KNullDesC8 )) |
1215 { |
1217 { |
1216 HBufC8* path8 = HBufC8::NewLC( path.Length() ); |
1218 HBufC8* path8 = HBufC8::NewLC( path.Length() ); |
1217 path8->Des().Copy( path ); |
1219 path8->Des().Copy( path ); |
1218 path8->Des().LowerCase(); |
1220 path8->Des().LowerCase(); |
1219 ParseSuiteUriPathL( *path8, *suiteNameArray ); |
1221 ParseSuiteUriPathL( *path8, *suiteNameArray ); |
1220 CleanupStack::PopAndDestroy( path8 ); |
1222 CleanupStack::PopAndDestroy( path8 ); |
1221 } |
1223 } |
1222 |
1224 |
1223 TBool suiteExists( EFalse ); |
1225 TBool suiteExists( EFalse ); |
1224 iMetaDataModel->IgnoreEvaluations( ETrue ); |
1226 iMetaDataModel->IgnoreEvaluations( ETrue ); |
1225 iMetaDataModel->QueueForeground( CHnMdModel::EWhenAnySuiteIsEvaluated ); |
1227 iMetaDataModel->QueueForeground( CHnMdModel::EWhenAnySuiteIsEvaluated ); |
1226 |
1228 |
1227 if( host8.Length() == 0 || ( host8.Length() > 0 && |
1229 if( host8.Length() == 0 || ( host8.Length() > 0 && |
1228 !iMetaDataModel->SuiteModelExistsL( host8 ) ) ) |
1230 !iMetaDataModel->SuiteModelExistsL( host8 ) ) ) |
1229 { |
1231 { |
1230 suiteNameArray->Reset(); |
1232 suiteNameArray->Reset(); |
1231 suiteNameArray->AppendL( KRoot8 ); |
1233 suiteNameArray->AppendL( KRoot8 ); |
1232 } |
1234 } |
1233 |
1235 |
1234 for( TInt i = 0; i < suiteNameArray->Count(); ++i ) |
1236 for( TInt i = 0; i < suiteNameArray->Count(); ++i ) |
1235 { |
1237 { |
1236 suiteExists = iMetaDataModel->SuiteModelExistsL( |
1238 suiteExists = iMetaDataModel->SuiteModelExistsL( |
1237 ( *suiteNameArray )[i] ); |
1239 ( *suiteNameArray )[i] ); |
1238 TBool nextExists = i < suiteNameArray->Count() - 1 && |
1240 TBool nextExists = i < suiteNameArray->Count() - 1 && |
1239 iMetaDataModel->SuiteModelExistsL( ( *suiteNameArray )[i + 1] ); |
1241 iMetaDataModel->SuiteModelExistsL( ( *suiteNameArray )[i + 1] ); |
1240 TBool isLast = ( i == ( suiteNameArray->Count() - 1 ) ); |
1242 TBool isLast = ( i == ( suiteNameArray->Count() - 1 ) ); |
1241 |
1243 |
1242 TBool turnOnEvaluation = ( suiteExists && ( !nextExists || isLast ) ); |
1244 TBool turnOnEvaluation = ( suiteExists && ( !nextExists || isLast ) ); |
1243 if( turnOnEvaluation || !suiteExists ) |
1245 if( turnOnEvaluation || !suiteExists ) |
1244 { |
1246 { |
1245 iMetaDataModel->IgnoreEvaluations( EFalse ); |
1247 iMetaDataModel->IgnoreEvaluations( EFalse ); |
1246 } |
1248 } |
1247 |
1249 |
1248 TInt err( KErrNone ); |
1250 TInt err( KErrNone ); |
1249 |
1251 |
1250 // Ignore loading new suite if the last suite in model is the same |
1252 // Ignore loading new suite if the last suite in model is the same |
1251 // as first one in the uri. |
1253 // as first one in the uri. |
1252 if ( i == 0 ) |
1254 if ( i == 0 ) |
1253 { |
1255 { |
1254 if ( SuitesAreTheSameL( iMetaDataModel->GetLastSuite()->SuiteName(), (*suiteNameArray)[i] ) ) |
1256 if ( SuitesAreTheSameL( iMetaDataModel->GetLastSuite()->SuiteName(), (*suiteNameArray)[i] ) ) |
1255 { |
1257 { |
1256 HandleTheSameSuitesL( nextExists, parser.Extract( EUriQuery ) ); |
1258 HandleTheSameSuitesL( nextExists, parser.Extract( EUriQuery ) ); |
1257 sendToForeground = ETrue; |
1259 sendToForeground = ETrue; |
1258 continue; |
1260 continue; |
1259 } |
1261 } |
1260 } |
1262 } |
1261 |
1263 |
|
1264 if( suiteExists ) |
|
1265 { |
|
1266 if (!nextExists) |
|
1267 { |
|
1268 // Tricky: queue foreground so that if the suite is evaluated synchronously |
|
1269 // the foreground will be gained. |
|
1270 iMetaDataModel->QueueForeground( CHnMdModel::EWhenAnySuiteIsEvaluated ); |
|
1271 } |
|
1272 err = LoadSuiteFromUriL( |
|
1273 ( *suiteNameArray )[i], parser.Extract( EUriQuery ), parser.Extract( EUriFragment ) ); |
|
1274 if ( KErrNone == err && !nextExists && iMetaDataModel->IsForegroundQueued() ) |
|
1275 { |
|
1276 // Tricky: if foreground is still queued it means that the suite is evaluated |
|
1277 // asynchronously. Override the previos foreground queue setting with one |
|
1278 // that will be effective only if the last loaded suite is evaluated. |
|
1279 iMetaDataModel->QueueForeground( CHnMdModel::EWhenCurrentTopSuiteIsEvaluated ); |
|
1280 } |
|
1281 if ( err != KErrNone ) |
|
1282 { |
|
1283 sendToForeground = ETrue; |
|
1284 } |
|
1285 } |
|
1286 |
|
1287 if( !suiteExists || err != KErrNone || !nextExists ) |
|
1288 { |
|
1289 CHnFilter* filter = CHnFilter::NewLC(); |
|
1290 |
|
1291 filter->SetSuiteId( |
|
1292 iSuiteContainer->GetLastSuiteModel()->CustomId() ); |
|
1293 |
|
1294 filter->SetEvaluateSuiteL( ETrue ); |
|
1295 iMetaDataModel->IgnoreEvaluations( EFalse ); |
|
1296 |
|
1297 TRAPD( err, iMetaDataModel->EvaluateL( *filter ) ); |
|
1298 |
|
1299 CleanupStack::PopAndDestroy( filter ); |
|
1300 if( err ) |
|
1301 { |
|
1302 iMetaDataModel->DeleteLastSuite(); |
|
1303 iSuiteContainer->PopSuiteModelL( |
|
1304 HnConvUtils::Str8ToStr( ( *suiteNameArray )[i] )->Des() ); |
|
1305 sendToForeground = ETrue; |
|
1306 } |
|
1307 break; |
|
1308 } |
|
1309 } |
|
1310 |
|
1311 // set highlight only when path is valid! |
1262 if( suiteExists ) |
1312 if( suiteExists ) |
1263 { |
1313 { |
1264 if (!nextExists) |
1314 HighlightPlacementFromUriL( parser.Extract( EUriFragment ) ); |
1265 { |
1315 } |
1266 // Tricky: queue foreground so that if the suite is evaluated synchronously |
|
1267 // the foreground will be gained. |
|
1268 iMetaDataModel->QueueForeground( CHnMdModel::EWhenAnySuiteIsEvaluated ); |
|
1269 } |
|
1270 err = LoadSuiteFromUriL( |
|
1271 ( *suiteNameArray )[i], parser.Extract( EUriQuery ), parser.Extract( EUriFragment ) ); |
|
1272 if ( KErrNone == err && !nextExists && iMetaDataModel->IsForegroundQueued() ) |
|
1273 { |
|
1274 // Tricky: if foreground is still queued it means that the suite is evaluated |
|
1275 // asynchronously. Override the previos foreground queue setting with one |
|
1276 // that will be effective only if the last loaded suite is evaluated. |
|
1277 iMetaDataModel->QueueForeground( CHnMdModel::EWhenCurrentTopSuiteIsEvaluated ); |
|
1278 } |
|
1279 if ( err != KErrNone ) |
|
1280 { |
|
1281 sendToForeground = ETrue; |
|
1282 } |
|
1283 } |
|
1284 |
|
1285 if( !suiteExists || err != KErrNone || !nextExists ) |
|
1286 { |
|
1287 CHnFilter* filter = CHnFilter::NewLC(); |
|
1288 |
|
1289 filter->SetSuiteId( |
|
1290 iSuiteContainer->GetLastSuiteModel()->CustomId() ); |
|
1291 |
|
1292 filter->SetEvaluateSuiteL( ETrue ); |
|
1293 iMetaDataModel->IgnoreEvaluations( EFalse ); |
|
1294 |
|
1295 TRAPD( err, iMetaDataModel->EvaluateL( *filter ) ); |
|
1296 |
|
1297 CleanupStack::PopAndDestroy( filter ); |
|
1298 if( err ) |
|
1299 { |
|
1300 iMetaDataModel->DeleteLastSuite(); |
|
1301 iSuiteContainer->PopSuiteModelL( |
|
1302 HnConvUtils::Str8ToStr( ( *suiteNameArray )[i] )->Des() ); |
|
1303 sendToForeground = ETrue; |
|
1304 } |
|
1305 break; |
|
1306 } |
|
1307 } |
|
1308 |
|
1309 // set highlight only when path is valid! |
|
1310 if( suiteExists ) |
|
1311 { |
|
1312 HighlightPlacementFromUriL( parser.Extract( EUriFragment ) ); |
|
1313 } |
|
1314 |
1316 |
1315 CleanupStack::PopAndDestroy( &host8 ); |
1317 CleanupStack::PopAndDestroy( &host8 ); |
1316 CleanupStack::PopAndDestroy( suiteNameArray ); |
1318 CleanupStack::PopAndDestroy( suiteNameArray ); |
1317 CleanupStack::PopAndDestroy( uriBuf ); |
1319 CleanupStack::PopAndDestroy( uriBuf ); |
1318 |
1320 |
1319 // send to foreground |
1321 // send to foreground |
1320 if ( sendToForeground ) |
1322 if ( sendToForeground ) |
1321 { |
1323 { |
1322 CLiwGenericParamList* pl = CLiwGenericParamList::NewL(); |
1324 CLiwGenericParamList* pl = CLiwGenericParamList::NewL(); |
1323 CleanupStack::PushL( pl ); |
1325 CleanupStack::PushL( pl ); |
1324 HandleModelEventL( KAppGainForeground, *pl ); |
1326 HandleModelEventL( KAppGainForeground, *pl ); |
1325 CleanupStack::PopAndDestroy( pl ); |
1327 CleanupStack::PopAndDestroy( pl ); |
1326 iMetaDataModel->QueueForeground( CHnMdModel::ENever ); |
1328 iMetaDataModel->QueueForeground( CHnMdModel::ENever ); |
1327 } |
1329 } |
1328 |
1330 |
1329 } |
1331 } |
|
1332 // --------------------------------------------------------------------------- |
|
1333 // |
|
1334 // --------------------------------------------------------------------------- |
|
1335 // |
|
1336 void CHnEngine::LoadItemFromCrL( const TDesC8& aUri ) |
|
1337 { |
|
1338 HBufC8* uriBuf = HBufC8::NewLC( aUri.Length() ); |
|
1339 uriBuf->Des().Copy( aUri ); |
|
1340 |
|
1341 TUriParser8 parser; |
|
1342 parser.Parse( *uriBuf ); |
|
1343 User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound ); |
|
1344 |
|
1345 const TDesC8& query = parser.Extract( EUriQuery ); |
|
1346 |
|
1347 if( query.Compare( KNullDesC8 ) ) |
|
1348 { |
|
1349 TBuf8<KMaxLength> item; |
|
1350 RPointerArray<HBufC8> paramValue = SplitL( query, |
|
1351 HnLogicalRelations::KLogicalEqual8 ); |
|
1352 CleanupResetAndDestroyPushL( paramValue ); |
|
1353 ASSERT( paramValue.Count() == 2 ); |
|
1354 |
|
1355 if( !paramValue[0]->Compare( KId8 ) ) |
|
1356 { |
|
1357 if( paramValue[1]->Length() <= KUidStringLength ) |
|
1358 { |
|
1359 item.Append( *paramValue[1] ); |
|
1360 } |
|
1361 } |
|
1362 CleanupStack::PopAndDestroy( ¶mValue ); |
|
1363 |
|
1364 TBuf<KMaxLength> item1; |
|
1365 item1.Copy( item ); |
|
1366 CRepository *cenRep = CRepository::NewLC( KCRUidMenu ); |
|
1367 cenRep->Set( KMenuOpenItem, item1 ); |
|
1368 CleanupStack::PopAndDestroy( cenRep ); |
|
1369 } |
|
1370 CleanupStack::PopAndDestroy( uriBuf ); |
|
1371 } |
1330 |
1372 |
1331 // End of file |
1373 // End of file |