menufw/hierarchynavigator/hnengine/src/hnengine.cpp
branchRCL_3
changeset 93 b01126ce0bec
parent 88 3321d3e205b6
child 102 ba63c83f4716
equal deleted inserted replaced
88:3321d3e205b6 93:b01126ce0bec
   266 //
   266 //
   267 // ---------------------------------------------------------------------------
   267 // ---------------------------------------------------------------------------
   268 //
   268 //
   269 EXPORT_C void CHnEngine::LoadSuitesFromUriL( const TDesC8& aUri )
   269 EXPORT_C void CHnEngine::LoadSuitesFromUriL( const TDesC8& aUri )
   270   {
   270   {
   271   DEBUG(("_MM_:CHnEngine::LoadSuitesFromUriL IN"));
   271     DEBUG(("_MM_:CHnEngine::LoadSuitesFromUriL IN"));
   272   DEBUG8(("_MM_:\tURI: %S",&aUri));
   272     DEBUG8(("_MM_:\tURI: %S",&aUri));
   273 
   273 
   274   TBool consumed(EFalse);
   274     TBool consumed( EFalse );
   275 
   275 
   276     if ( aUri.Find( KSetFocusWithPref ) != KErrNotFound )
   276     if( aUri.Find( KSetFocusWithPref ) != KErrNotFound )
   277       {
   277         {
   278       LoadFromCrL( aUri );
   278         LoadFromCrL( aUri );
   279       consumed = ETrue;
   279         consumed = ETrue;
   280       }
   280         }
   281 
   281     else if( aUri.Find( KOpenItemWithPref ) != KErrNotFound )
   282     if ( !consumed )
   282         {
   283       {
   283         LoadItemFromCrL( aUri );
   284       consumed = HandleActionL( aUri );
   284         consumed = ETrue;
   285       }
   285         }
   286 
   286 
   287     if ( !consumed )
   287     if( !consumed )
   288       {
   288         {
   289       LoadSuitesL( aUri );
   289         consumed = HandleActionL( aUri );
   290       }
   290         }
       
   291 
       
   292     if( !consumed )
       
   293         {
       
   294         LoadSuitesL( aUri );
       
   295         }
   291 
   296 
   292     DEBUG(("_MM_:CHnEngine::LoadSuitesFromUriL OUT"));
   297     DEBUG(("_MM_:CHnEngine::LoadSuitesFromUriL OUT"));
   293     }
   298     }
   294 
   299 
   295 // ---------------------------------------------------------------------------
   300 // ---------------------------------------------------------------------------
   600     // that suite given by the name genre has been
   605     // that suite given by the name genre has been
   601     DEBUG(("_MM_:CHnEngine::HandleSetFocusEventL IN"));
   606     DEBUG(("_MM_:CHnEngine::HandleSetFocusEventL IN"));
   602 
   607 
   603     TInt posSuite( 0 );
   608     TInt posSuite( 0 );
   604     TInt posItem( 0 );
   609     TInt posItem( 0 );
   605   TInt64 suiteCustomId( KErrNotFound );
   610     TInt64 suiteCustomId( KErrNotFound );
   606   TInt64 itemCustomId( KErrNotFound );
   611     TInt64 itemCustomId( KErrNotFound );
   607 
   612 
   608   // Get suite's and item's custom ids.
   613   // Get suite's and item's custom ids.
   609   const TLiwGenericParam* paramSuiteId = aParams.FindFirst( posSuite,  KSuiteCustomId8 );
   614   const TLiwGenericParam* paramSuiteId = aParams.FindFirst( posSuite,  KSuiteCustomId8 );
   610   const TLiwGenericParam* paramItemId = aParams.FindFirst( posItem,  KItemCustomId8 );
   615   const TLiwGenericParam* paramItemId = aParams.FindFirst( posItem,  KItemCustomId8 );
   611 
   616 
   886     CleanupResetAndDestroyPushL( tokens );
   891     CleanupResetAndDestroyPushL( tokens );
   887 
   892 
   888     if ( aSource.Length() > 0 && aSeparator.Length() > 0 )
   893     if ( aSource.Length() > 0 && aSeparator.Length() > 0 )
   889         {
   894         {
   890         TPtrC8 tmpSource = aSource;
   895         TPtrC8 tmpSource = aSource;
   891 
       
   892         TPtrC8 token( KNullDesC8 );
   896         TPtrC8 token( KNullDesC8 );
   893 
   897 
   894         while( ETrue )
   898         while( ETrue )
   895             {
   899             {
   896             TInt length = tmpSource.Find( aSeparator );
   900             TInt length = tmpSource.Find( aSeparator );
   897 
   901 
   898             if( aSeparator == HnLogicalRelations::KParamUid8
   902             if( aSeparator == HnLogicalRelations::KParamUid8
   899                     && length != KErrNotFound )
   903                     && length != KErrNotFound )
   900                 {
   904                 {
   901                 TInt ampPos( KErrNotFound );
   905                 TInt ampPos( KErrNotFound );
   902                 TInt eqPos( KErrNotFound );
       
   903                 do
   906                 do
   904                     {
   907                     {
   905                     ampPos = tmpSource.Mid(
   908                     ampPos = tmpSource.Mid(
   906                             length + HnLogicalRelations::KParamUid8().Length() ).
   909                             length + HnLogicalRelations::KParamUid8().Length() ).
   907                                 Find( HnLogicalRelations::KLogicalAnd8 );
   910                                 Find( HnLogicalRelations::KLogicalAnd8 );
   910                         length += (ampPos + HnLogicalRelations::KParamUid8().Length());
   913                         length += (ampPos + HnLogicalRelations::KParamUid8().Length());
   911                         ampPos = 0;
   914                         ampPos = 0;
   912                         }
   915                         }
   913                     else if( (length + HnLogicalRelations::KParamUid8().Length())
   916                     else if( (length + HnLogicalRelations::KParamUid8().Length())
   914                                 == tmpSource.Length())
   917                                 == tmpSource.Length())
   915                         {    
   918                         {
   916                         length = KErrNotFound;
   919                         length = KErrNotFound;
   917                         }
   920                         }
   918                     }while( !ampPos );
   921                     }while( !ampPos );
   919                 }
   922                 }
   920 
   923 
  1031     User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound );
  1034     User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound );
  1032 
  1035 
  1033     const TDesC8& query = parser.Extract( EUriQuery );
  1036     const TDesC8& query = parser.Extract( EUriQuery );
  1034     RPointerArray< HBufC8 > params = SplitL( query, HnLogicalRelations::KParamUid8);
  1037     RPointerArray< HBufC8 > params = SplitL( query, HnLogicalRelations::KParamUid8);
  1035 
  1038 
  1036     TBuf8<KApaMaxAppGroupName + KTimeStampBufferLength + KUidStringLength + 2> item;
  1039     TBuf8< KApaMaxAppGroupName + KTimeStampBufferLength + KUidStringLength + 2> item;
  1037 
  1040 
  1038     for( TInt i = 0; i < params.Count(); i++ )
  1041     for( TInt i = 0; i < params.Count(); i++ )
  1039         {
  1042         {
  1040         RPointerArray< HBufC8 > paramValue = SplitL( *params[ i ], HnLogicalRelations::KLogicalEqual8 );
  1043         RPointerArray< HBufC8 > paramValue = SplitL( *params[ i ], HnLogicalRelations::KLogicalEqual8 );
  1041         CleanupResetAndDestroyPushL( paramValue );
  1044         CleanupResetAndDestroyPushL( paramValue );
  1042         ASSERT( paramValue.Count() == 2 );
  1045         ASSERT( paramValue.Count() == 2 );
  1043 
  1046 
  1044         if ( !paramValue[0]->Compare(KMcsAppGroupName8) )
  1047         if ( !paramValue[0]->Compare(KMcsAppGroupName8) )
  1045         	{
  1048           {
  1046         	TBuf8<KApaMaxAppGroupName> appgrname;
  1049           TBuf8< KApaMaxAppGroupName > appgrname;
  1047         	if( paramValue[1]->Length()<=KApaMaxAppGroupName )
  1050           if( paramValue[1]->Length()<= KApaMaxAppGroupName )
  1048         	    {
  1051               {
  1049         	    appgrname.Append( *paramValue[1] );
  1052               appgrname.Append( *paramValue[1] );
  1050         	    }
  1053               }
  1051 
  1054 
  1052           //get current time
  1055           //get current time
  1053           TTime currentTime;
  1056           TTime currentTime;
  1054           currentTime.HomeTime();
  1057           currentTime.HomeTime();
  1055           TDateTime date(currentTime.DateTime());
  1058           TDateTime date(currentTime.DateTime());
  1065                 }
  1068                 }
  1066           }
  1069           }
  1067         CleanupStack::PopAndDestroy( &paramValue );
  1070         CleanupStack::PopAndDestroy( &paramValue );
  1068         }
  1071         }
  1069 
  1072 
  1070     TBuf<KApaMaxAppGroupName + KTimeStampBufferLength + KUidStringLength + 2> item1;
  1073     TBuf< KApaMaxAppGroupName + KTimeStampBufferLength + KUidStringLength + 2> item1;
  1071     item1.Copy(item);
  1074     item1.Copy(item);
  1072     CRepository *cenRep = CRepository::NewLC( KCRUidMenu );
  1075     CRepository *cenRep = CRepository::NewLC( KCRUidMenu );
  1073     cenRep->Set(KMenuShowFolder, item1);
  1076     cenRep->Set(KMenuShowFolder, item1);
  1074     CleanupStack::PopAndDestroy( cenRep );
  1077     CleanupStack::PopAndDestroy( cenRep );
  1075 
  1078 
  1076     params.ResetAndDestroy();
  1079     params.ResetAndDestroy();
  1077     CleanupStack::PopAndDestroy( uriBuf );
  1080     CleanupStack::PopAndDestroy( uriBuf );
  1078 
       
  1079   }
  1081   }
  1080 // ---------------------------------------------------------------------------
  1082 // ---------------------------------------------------------------------------
  1081 //
  1083 //
  1082 // ---------------------------------------------------------------------------
  1084 // ---------------------------------------------------------------------------
  1083 //
  1085 //
  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( &paramValue );
       
  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