menufw/hierarchynavigator/hnengine/src/hnengine.cpp
branchRCL_3
changeset 35 3321d3e205b6
parent 34 5456b4e8b3a8
equal deleted inserted replaced
34:5456b4e8b3a8 35:3321d3e205b6
   190     TInt error( KErrNone );
   190     TInt error( KErrNone );
   191 
   191 
   192     if( !( aSuiteName.Compare( KRoot8 ) ) )
   192     if( !( aSuiteName.Compare( KRoot8 ) ) )
   193         {
   193         {
   194         CLiwGenericParamList* uriParams =
   194         CLiwGenericParamList* uriParams =
   195 			UriQueryToLiwListLC( aUriQuery, aUriFragment, aSuiteName );
   195       UriQueryToLiwListLC( aUriQuery, aUriFragment, aSuiteName );
   196         CLiwGenericParamList* params = CLiwGenericParamList::NewLC();
   196         CLiwGenericParamList* params = CLiwGenericParamList::NewLC();
   197         params->AppendL( iMetaDataModel->GetSuiteParameters( 0 ) );
   197         params->AppendL( iMetaDataModel->GetSuiteParameters( 0 ) );
   198         params->AppendL( *uriParams );
   198         params->AppendL( *uriParams );
   199         ResetModelsL();
   199         ResetModelsL();
   200         iMetaDataModel->QueueForeground( CHnMdModel::EWhenAnySuiteIsEvaluated );
   200         iMetaDataModel->QueueForeground( CHnMdModel::EWhenAnySuiteIsEvaluated );
   203         CleanupStack::PopAndDestroy( uriParams );
   203         CleanupStack::PopAndDestroy( uriParams );
   204         }
   204         }
   205     else
   205     else
   206         {
   206         {
   207         CLiwGenericParamList* params =
   207         CLiwGenericParamList* params =
   208 			UriQueryToLiwListLC( aUriQuery, aUriFragment, aSuiteName );
   208       UriQueryToLiwListLC( aUriQuery, aUriFragment, aSuiteName );
   209 
   209 
   210         HBufC* suiteName = HnConvUtils::Str8ToStrLC( aSuiteName );
   210         HBufC* suiteName = HnConvUtils::Str8ToStrLC( aSuiteName );
   211         params->AppendL( TLiwGenericParam( KNewSuiteParamNameEn,
   211         params->AppendL( TLiwGenericParam( KNewSuiteParamNameEn,
   212             TLiwVariant( *suiteName ) ) );
   212             TLiwVariant( *suiteName ) ) );
   213 
   213 
   265 // ---------------------------------------------------------------------------
   265 // ---------------------------------------------------------------------------
   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 
   282     if ( !consumed )
   282     if ( !consumed )
   283     	{
   283       {
   284     	consumed = HandleActionL( aUri );
   284       consumed = HandleActionL( aUri );
   285     	}
   285       }
   286 
   286 
   287     if ( !consumed )
   287     if ( !consumed )
   288     	{
   288       {
   289     	LoadSuitesL( aUri );
   289       LoadSuitesL( aUri );
   290     	}
   290       }
   291 
   291 
   292     DEBUG(("_MM_:CHnEngine::LoadSuitesFromUriL OUT"));
   292     DEBUG(("_MM_:CHnEngine::LoadSuitesFromUriL OUT"));
   293     }
   293     }
   294 
   294 
   295 // ---------------------------------------------------------------------------
   295 // ---------------------------------------------------------------------------
   351         {
   351         {
   352         // SetFocus
   352         // SetFocus
   353         ret = HandleSetFocusEventL( aParams );
   353         ret = HandleSetFocusEventL( aParams );
   354         }
   354         }
   355     else if (aEventName == KAppGainForeground )
   355     else if (aEventName == KAppGainForeground )
   356     	{
   356       {
   357     	//force matrix gain foreground
   357       //force matrix gain foreground
   358         DEBUG(("_MM_:CHnEngine::HandleModelEventL EForegroundGain"));
   358         DEBUG(("_MM_:CHnEngine::HandleModelEventL EForegroundGain"));
   359         iControllerInterface.NotifyUiRefreshL( EForegroundGain );
   359         iControllerInterface.NotifyUiRefreshL( EForegroundGain );
   360         ret = KErrNone;
   360         ret = KErrNone;
   361     	}
   361       }
   362     else if (aEventName == KAppGainBackground )
   362     else if (aEventName == KAppGainBackground )
   363     	{
   363       {
   364     	//force matrix gain background
   364       //force matrix gain background
   365         DEBUG(("_MM_:CHnEngine::HandleModelEventL EBackgroundGain"));
   365         DEBUG(("_MM_:CHnEngine::HandleModelEventL EBackgroundGain"));
   366         iControllerInterface.NotifyUiRefreshL( EBackgroundGain );
   366         iControllerInterface.NotifyUiRefreshL( EBackgroundGain );
   367         ret = KErrNone;
   367         ret = KErrNone;
   368     	}
   368       }
   369 
   369 
   370     return ret;
   370     return ret;
   371     }
   371     }
   372 
   372 
   373 // ---------------------------------------------------------------------------
   373 // ---------------------------------------------------------------------------
   600     // that suite given by the name genre has been
   600     // that suite given by the name genre has been
   601     DEBUG(("_MM_:CHnEngine::HandleSetFocusEventL IN"));
   601     DEBUG(("_MM_:CHnEngine::HandleSetFocusEventL IN"));
   602 
   602 
   603     TInt posSuite( 0 );
   603     TInt posSuite( 0 );
   604     TInt posItem( 0 );
   604     TInt posItem( 0 );
   605 	TInt64 suiteCustomId( KErrNotFound );
   605   TInt64 suiteCustomId( KErrNotFound );
   606 	TInt64 itemCustomId( KErrNotFound );
   606   TInt64 itemCustomId( KErrNotFound );
   607 
   607 
   608 	// Get suite's and item's custom ids.
   608   // Get suite's and item's custom ids.
   609 	const TLiwGenericParam* paramSuiteId = aParams.FindFirst( posSuite,  KSuiteCustomId8 );
   609   const TLiwGenericParam* paramSuiteId = aParams.FindFirst( posSuite,  KSuiteCustomId8 );
   610 	const TLiwGenericParam* paramItemId = aParams.FindFirst( posItem,  KItemCustomId8 );
   610   const TLiwGenericParam* paramItemId = aParams.FindFirst( posItem,  KItemCustomId8 );
   611 
   611 
   612 
   612 
   613 	if ( posSuite >= 0 && posItem >= 0 )
   613   if ( posSuite >= 0 && posItem >= 0 )
   614     	{
   614       {
   615     	suiteCustomId = paramSuiteId->Value().AsTInt64();
   615       suiteCustomId = paramSuiteId->Value().AsTInt64();
   616     	itemCustomId = paramItemId->Value().AsTInt64();
   616       itemCustomId = paramItemId->Value().AsTInt64();
   617 
   617 
   618     	// Get matching suite.
   618       // Get matching suite.
   619     	CHnSuiteModel* suiteModel = iSuiteContainer->GetMatchingSuiteModel( suiteCustomId );
   619       CHnSuiteModel* suiteModel = iSuiteContainer->GetMatchingSuiteModel( suiteCustomId );
   620 
   620 
   621     	if ( suiteModel )
   621       if ( suiteModel )
   622     		{
   622         {
   623     		// If suite is not null, then find matching item model.
   623         // If suite is not null, then find matching item model.
   624     		TInt index( KErrNotFound );
   624         TInt index( KErrNotFound );
   625     		CHnItemModel* itemModel = suiteModel->GetMatchingItemModelL( itemCustomId, index );
   625         CHnItemModel* itemModel = suiteModel->GetMatchingItemModelL( itemCustomId, index );
   626 
   626 
   627     		if ( itemModel )
   627         if ( itemModel )
   628     			{
   628           {
   629     			// If itemModel is not null then set highlight and set highligh
   629           // If itemModel is not null then set highlight and set highligh
   630     			// on matching item.
   630           // on matching item.
   631     			suiteModel->SetSuiteHighlightL( index );
   631           suiteModel->SetSuiteHighlightL( index );
   632         		iControllerInterface.HandleSuiteEventL( ESuiteHighlightChanged, suiteModel );
   632             iControllerInterface.HandleSuiteEventL( ESuiteHighlightChanged, suiteModel );
   633     			}
   633           }
   634     		else
   634         else
   635     			{
   635           {
   636     			suiteModel->QueueFocus( itemCustomId );
   636           suiteModel->QueueFocus( itemCustomId );
   637     			}
   637           }
   638     		}
   638         }
   639     	}
   639       }
   640 
   640 
   641     DEBUG(("_MM_:CHnEngine::HandleSetFocusEventL OUT"));
   641     DEBUG(("_MM_:CHnEngine::HandleSetFocusEventL OUT"));
   642     return KErrNone;
   642     return KErrNone;
   643     }
   643     }
   644 
   644 
   893 
   893 
   894         while( ETrue )
   894         while( ETrue )
   895             {
   895             {
   896             TInt length = tmpSource.Find( aSeparator );
   896             TInt length = tmpSource.Find( aSeparator );
   897 
   897 
       
   898             if( aSeparator == HnLogicalRelations::KParamUid8
       
   899                     && length != KErrNotFound )
       
   900                 {
       
   901                 TInt ampPos( KErrNotFound );
       
   902                 TInt eqPos( KErrNotFound );
       
   903                 do
       
   904                     {
       
   905                     ampPos = tmpSource.Mid(
       
   906                             length + HnLogicalRelations::KParamUid8().Length() ).
       
   907                                 Find( HnLogicalRelations::KLogicalAnd8 );
       
   908                     if( ampPos >= 0 )
       
   909                         {
       
   910                         length += (ampPos + HnLogicalRelations::KParamUid8().Length());
       
   911                         ampPos = 0;
       
   912                         }
       
   913                     else if( (length + HnLogicalRelations::KParamUid8().Length())
       
   914                                 == tmpSource.Length())
       
   915                         {    
       
   916                         length = KErrNotFound;
       
   917                         }
       
   918                     }while( !ampPos );
       
   919                 }
       
   920 
   898             if ( length >= 0 )
   921             if ( length >= 0 )
   899                 {
   922                 {
   900                 token.Set( tmpSource.Mid( 0, length ) );
   923                 token.Set( tmpSource.Mid( 0, length ) );
   901                 tokens.AppendL( token.AllocL() );
   924                 tokens.AppendL( token.AllocL() );
   902                 tmpSource.Set( tmpSource.Mid( length + 1 ) );
   925                 tmpSource.Set( tmpSource.Mid( length + 1 ) );
       
   926                 if( aSeparator == HnLogicalRelations::KLogicalEqual8 )
       
   927                     {
       
   928                     token.Set( tmpSource );
       
   929                     tokens.AppendL( token.AllocL() );
       
   930                     break;
       
   931                     }
   903                 }
   932                 }
   904             else
   933             else
   905                 {
   934                 {
   906                 token.Set( tmpSource );
   935                 token.Set( tmpSource );
   907                 tokens.AppendL( token.AllocL() );
   936                 tokens.AppendL( token.AllocL() );
   991 // ---------------------------------------------------------------------------
  1020 // ---------------------------------------------------------------------------
   992 //
  1021 //
   993 // ---------------------------------------------------------------------------
  1022 // ---------------------------------------------------------------------------
   994 //
  1023 //
   995 void CHnEngine::LoadFromCrL( const TDesC8& aUri )
  1024 void CHnEngine::LoadFromCrL( const TDesC8& aUri )
   996 	{
  1025     {
   997 	HBufC8* uriBuf = HBufC8::NewLC( aUri.Length() );
  1026     HBufC8* uriBuf = HBufC8::NewLC( aUri.Length() );
   998 	uriBuf->Des().Copy( aUri );
  1027     uriBuf->Des().Copy( aUri );
   999 
  1028 
  1000 	TUriParser8 parser;
  1029     TUriParser8 parser;
  1001 	parser.Parse( *uriBuf );
  1030     parser.Parse( *uriBuf );
  1002 	User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound );
  1031     User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound );
  1003 
  1032 
  1004 	const TDesC8& query = parser.Extract( EUriQuery );
  1033     const TDesC8& query = parser.Extract( EUriQuery );
  1005     RPointerArray< HBufC8 > params = SplitL( query, HnLogicalRelations::KLogicalAnd8);
  1034     RPointerArray< HBufC8 > params = SplitL( query, HnLogicalRelations::KParamUid8);
  1006 
  1035 
  1007     TBuf8<KApaMaxAppGroupName + KTimeStampBufferLength + KUidStringLength + 2> item;
  1036     TBuf8<KApaMaxAppGroupName + KTimeStampBufferLength + KUidStringLength + 2> item;
  1008 
  1037 
  1009     for( TInt i = 0; i < params.Count(); i++ )
  1038     for( TInt i = 0; i < params.Count(); i++ )
  1010         {
  1039         {
  1018         	if( paramValue[1]->Length()<=KApaMaxAppGroupName )
  1047         	if( paramValue[1]->Length()<=KApaMaxAppGroupName )
  1019         	    {
  1048         	    {
  1020         	    appgrname.Append( *paramValue[1] );
  1049         	    appgrname.Append( *paramValue[1] );
  1021         	    }
  1050         	    }
  1022 
  1051 
  1023         	//get current time
  1052           //get current time
  1024         	TTime currentTime;
  1053           TTime currentTime;
  1025         	currentTime.HomeTime();
  1054           currentTime.HomeTime();
  1026         	TDateTime date(currentTime.DateTime());
  1055           TDateTime date(currentTime.DateTime());
  1027         	item.Format(KCRepTimeFormat, &appgrname , date.Year(), date.Month(),
  1056           item.Format(KCRepTimeFormat, &appgrname , date.Year(), date.Month(),
  1028         		date.Day(), date.Hour(), date.Minute(), date.Second(), date.MicroSecond());
  1057             date.Day(), date.Hour(), date.Minute(), date.Second(), date.MicroSecond());
  1029         	}
  1058           }
  1030         else if ( !paramValue[0]->Compare( KKeyTypeUid ) )
  1059         else if ( !paramValue[0]->Compare( KKeyTypeUid ) )
  1031         	{
  1060           {
  1032         	item.Append( KComma8 );
  1061           item.Append( KComma8 );
  1033             if( paramValue[1]->Length()<=KUidStringLength )
  1062             if( paramValue[1]->Length()<=KUidStringLength )
  1034                 {
  1063                 {
  1035                 item.Append( *paramValue[1] );
  1064                 item.Append( *paramValue[1] );
  1036                 }
  1065                 }
  1037         	}
  1066           }
  1038         CleanupStack::PopAndDestroy( &paramValue );
  1067         CleanupStack::PopAndDestroy( &paramValue );
  1039         }
  1068         }
  1040 
  1069 
  1041     TBuf<KApaMaxAppGroupName + KTimeStampBufferLength + KUidStringLength + 2> item1;
  1070     TBuf<KApaMaxAppGroupName + KTimeStampBufferLength + KUidStringLength + 2> item1;
  1042     item1.Copy(item);
  1071     item1.Copy(item);
  1043 	CRepository *cenRep = CRepository::NewLC( KCRUidMenu );
  1072     CRepository *cenRep = CRepository::NewLC( KCRUidMenu );
  1044 	cenRep->Set(KMenuShowFolder, item1);
  1073     cenRep->Set(KMenuShowFolder, item1);
  1045 	CleanupStack::PopAndDestroy( cenRep );
  1074     CleanupStack::PopAndDestroy( cenRep );
  1046 
  1075 
  1047     params.ResetAndDestroy();
  1076     params.ResetAndDestroy();
  1048     CleanupStack::PopAndDestroy( uriBuf );
  1077     CleanupStack::PopAndDestroy( uriBuf );
  1049 
  1078 
  1050 	}
  1079   }
  1051 // ---------------------------------------------------------------------------
  1080 // ---------------------------------------------------------------------------
  1052 //
  1081 //
  1053 // ---------------------------------------------------------------------------
  1082 // ---------------------------------------------------------------------------
  1054 //
  1083 //
  1055 void CHnEngine::LightStatusChanged(TInt aTarget,
  1084 void CHnEngine::LightStatusChanged(TInt aTarget,
  1079 // ---------------------------------------------------------------------------
  1108 // ---------------------------------------------------------------------------
  1080 //
  1109 //
  1081 // ---------------------------------------------------------------------------
  1110 // ---------------------------------------------------------------------------
  1082 //
  1111 //
  1083 TBool CHnEngine::HandleActionL( const TDesC8& aUri )
  1112 TBool CHnEngine::HandleActionL( const TDesC8& aUri )
  1084 	{
  1113   {
  1085 	TBool exitActionConsumed(EFalse);
  1114   TBool exitActionConsumed(EFalse);
  1086 
  1115 
  1087 	HBufC8* uriBuf = HBufC8::NewLC( aUri.Length() );
  1116   HBufC8* uriBuf = HBufC8::NewLC( aUri.Length() );
  1088 	uriBuf->Des().Copy( aUri );
  1117   uriBuf->Des().Copy( aUri );
  1089 
  1118 
  1090 	TUriParser8 parser;
  1119   TUriParser8 parser;
  1091     parser.Parse( *uriBuf );
  1120     parser.Parse( *uriBuf );
  1092     User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound );
  1121     User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound );
  1093 
  1122 
  1094     const TDesC8& host8 = parser.Extract( EUriHost );
  1123     const TDesC8& host8 = parser.Extract( EUriHost );
  1095     const TDesC8& query = parser.Extract( EUriQuery );
  1124     const TDesC8& query = parser.Extract( EUriQuery );
  1096 
  1125 
  1097 	RBuf action;
  1126   RBuf action;
  1098     CleanupClosePushL( action );
  1127     CleanupClosePushL( action );
  1099     CLiwGenericParamList* paramsUri = UriQueryToLiwListLC( query, KNullDesC8, KNullDesC8 );
  1128     CLiwGenericParamList* paramsUri = UriQueryToLiwListLC( query, KNullDesC8, KNullDesC8 );
  1100     HnLiwUtils::GetStringL( *paramsUri, KActionParams, action );
  1129     HnLiwUtils::GetStringL( *paramsUri, KActionParams, action );
  1101 
  1130 
  1102     if ( !action.Compare( KActionExit ) )
  1131     if ( !action.Compare( KActionExit ) )
  1103     	{
  1132       {
  1104     	RBuf host;
  1133       RBuf host;
  1105 		host.CreateL( host8.Length() );
  1134     host.CreateL( host8.Length() );
  1106 		CleanupClosePushL( host );
  1135     CleanupClosePushL( host );
  1107 		host.Copy(host8);
  1136     host.Copy(host8);
  1108     	CHnSuiteModel* suiteModel = iSuiteContainer->GetSuiteModel( host );
  1137       CHnSuiteModel* suiteModel = iSuiteContainer->GetSuiteModel( host );
  1109     	TBool exitHideHostNotFound( ETrue  );
  1138       TBool exitHideHostNotFound( ETrue  );
  1110     	if( suiteModel  && suiteModel->ExitMode() == EExitModeHide )
  1139       if( suiteModel  && suiteModel->ExitMode() == EExitModeHide )
  1111     	    {
  1140           {
  1112     	    exitHideHostNotFound = EFalse;
  1141           exitHideHostNotFound = EFalse;
  1113     	    }
  1142           }
  1114 
  1143 
  1115 		if ( exitHideHostNotFound )
  1144     if ( exitHideHostNotFound )
  1116 			{
  1145       {
  1117 			//send to foreground
  1146       //send to foreground
  1118 			CLiwGenericParamList* pl = CLiwGenericParamList::NewL();
  1147       CLiwGenericParamList* pl = CLiwGenericParamList::NewL();
  1119 			CleanupStack::PushL( pl );
  1148       CleanupStack::PushL( pl );
  1120 			HandleModelEventL( KAppGainForeground, *pl );
  1149       HandleModelEventL( KAppGainForeground, *pl );
  1121 			CleanupStack::PopAndDestroy( pl );
  1150       CleanupStack::PopAndDestroy( pl );
  1122 			}
  1151       }
  1123 		else
  1152     else
  1124 			{
  1153       {
  1125 			//send to background
  1154       //send to background
  1126 			CLiwGenericParamList* pl = CLiwGenericParamList::NewL();
  1155       CLiwGenericParamList* pl = CLiwGenericParamList::NewL();
  1127 			CleanupStack::PushL( pl );
  1156       CleanupStack::PushL( pl );
  1128 			HandleModelEventL( KAppGainBackground, *pl );
  1157       HandleModelEventL( KAppGainBackground, *pl );
  1129 			CleanupStack::PopAndDestroy( pl );
  1158       CleanupStack::PopAndDestroy( pl );
  1130 			}
  1159       }
  1131 
  1160 
  1132     	if ( exitHideHostNotFound && iSuiteContainer->GetLastSuiteModel() == suiteModel  )
  1161       if ( exitHideHostNotFound && iSuiteContainer->GetLastSuiteModel() == suiteModel  )
  1133     		{
  1162         {
  1134             HandleBackEventL( host,  1 );
  1163             HandleBackEventL( host,  1 );
  1135     		}
  1164         }
  1136     	else
  1165       else
  1137     		{
  1166         {
  1138         	//reset to root
  1167           //reset to root
  1139             CLiwGenericParamList* params = CLiwGenericParamList::NewLC();
  1168             CLiwGenericParamList* params = CLiwGenericParamList::NewLC();
  1140             params->AppendL( iMetaDataModel->GetSuiteParameters( 0 ) );
  1169             params->AppendL( iMetaDataModel->GetSuiteParameters( 0 ) );
  1141         	ResetModelsL();
  1170           ResetModelsL();
  1142             InitializeL( *params );
  1171             InitializeL( *params );
  1143             CleanupStack::PopAndDestroy( params );
  1172             CleanupStack::PopAndDestroy( params );
  1144     		}
  1173         }
  1145 
  1174 
  1146     	CleanupStack::PopAndDestroy( &host );
  1175       CleanupStack::PopAndDestroy( &host );
  1147     	exitActionConsumed = ETrue;
  1176       exitActionConsumed = ETrue;
  1148     	}
  1177       }
  1149 
  1178 
  1150     CleanupStack::PopAndDestroy( paramsUri );
  1179     CleanupStack::PopAndDestroy( paramsUri );
  1151     CleanupStack::PopAndDestroy( &action );
  1180     CleanupStack::PopAndDestroy( &action );
  1152     CleanupStack::PopAndDestroy( uriBuf );
  1181     CleanupStack::PopAndDestroy( uriBuf );
  1153     return exitActionConsumed;
  1182     return exitActionConsumed;
  1154 	}
  1183   }
  1155 
  1184 
  1156 // ---------------------------------------------------------------------------
  1185 // ---------------------------------------------------------------------------
  1157 //
  1186 //
  1158 // ---------------------------------------------------------------------------
  1187 // ---------------------------------------------------------------------------
  1159 //
  1188 //
  1160 void CHnEngine::LoadSuitesL( const TDesC8& aUri )
  1189 void CHnEngine::LoadSuitesL( const TDesC8& aUri )
  1161 	{
  1190   {
  1162 	TBool sendToForeground(EFalse);
  1191   TBool sendToForeground(EFalse);
  1163 	HBufC8* uriBuf = HBufC8::NewLC( aUri.Length() );
  1192   HBufC8* uriBuf = HBufC8::NewLC( aUri.Length() );
  1164 	uriBuf->Des().Copy( aUri );
  1193   uriBuf->Des().Copy( aUri );
  1165 
  1194 
  1166 	TUriParser8 parser;
  1195   TUriParser8 parser;
  1167 	parser.Parse( *uriBuf );
  1196   parser.Parse( *uriBuf );
  1168 	User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound );
  1197   User::LeaveIfError( parser.IsSchemeValid() ? KErrNone : KErrPathNotFound );
  1169 
  1198 
  1170 	CDesC8ArrayFlat* suiteNameArray = new( ELeave ) CDesC8ArrayFlat( KDefaultGranularity ) ;
  1199   CDesC8ArrayFlat* suiteNameArray = new( ELeave ) CDesC8ArrayFlat( KDefaultGranularity ) ;
  1171 	CleanupStack::PushL( suiteNameArray );
  1200   CleanupStack::PushL( suiteNameArray );
  1172 
  1201 
  1173 	const TDesC8& host = parser.Extract( EUriHost );
  1202   const TDesC8& host = parser.Extract( EUriHost );
  1174     RBuf8 host8;
  1203     RBuf8 host8;
  1175     CleanupClosePushL( host8 );
  1204     CleanupClosePushL( host8 );
  1176     if (host.Compare( KNullDesC8 ))
  1205     if (host.Compare( KNullDesC8 ))
  1177         {
  1206         {
  1178         host8.CreateL( host );
  1207         host8.CreateL( host );
  1179         host8.LowerCase();
  1208         host8.LowerCase();
  1180         suiteNameArray->AppendL( host8 );
  1209         suiteNameArray->AppendL( host8 );
  1181         DEBUG8(( "_MM_:\tURI host part: %S", &host8 ));
  1210         DEBUG8(( "_MM_:\tURI host part: %S", &host8 ));
  1182         }
  1211         }
  1183 
  1212 
  1184 	const TDesC8& path = parser.Extract( EUriPath );
  1213   const TDesC8& path = parser.Extract( EUriPath );
  1185 	if (path.Compare( KNullDesC8 ))
  1214   if (path.Compare( KNullDesC8 ))
  1186 		{
  1215     {
  1187 		HBufC8* path8 = HBufC8::NewLC( path.Length() );
  1216     HBufC8* path8 = HBufC8::NewLC( path.Length() );
  1188 		path8->Des().Copy( path );
  1217     path8->Des().Copy( path );
  1189 		path8->Des().LowerCase();
  1218     path8->Des().LowerCase();
  1190 		ParseSuiteUriPathL( *path8, *suiteNameArray );
  1219     ParseSuiteUriPathL( *path8, *suiteNameArray );
  1191 		CleanupStack::PopAndDestroy( path8 );
  1220     CleanupStack::PopAndDestroy( path8 );
  1192 		}
  1221     }
  1193 
  1222 
  1194 	TBool suiteExists( EFalse );
  1223   TBool suiteExists( EFalse );
  1195 	iMetaDataModel->IgnoreEvaluations( ETrue );
  1224   iMetaDataModel->IgnoreEvaluations( ETrue );
  1196 	iMetaDataModel->QueueForeground( CHnMdModel::EWhenAnySuiteIsEvaluated );
  1225   iMetaDataModel->QueueForeground( CHnMdModel::EWhenAnySuiteIsEvaluated );
  1197 
  1226 
  1198     if( host8.Length() == 0 || ( host8.Length() > 0 &&
  1227     if( host8.Length() == 0 || ( host8.Length() > 0 &&
  1199             !iMetaDataModel->SuiteModelExistsL( host8 ) ) )
  1228             !iMetaDataModel->SuiteModelExistsL( host8 ) ) )
  1200         {
  1229         {
  1201         suiteNameArray->Reset();
  1230         suiteNameArray->Reset();
  1202         suiteNameArray->AppendL( KRoot8 );
  1231         suiteNameArray->AppendL( KRoot8 );
  1203         }
  1232         }
  1204 
  1233 
  1205 	for( TInt i = 0; i < suiteNameArray->Count(); ++i )
  1234   for( TInt i = 0; i < suiteNameArray->Count(); ++i )
  1206 		{
  1235     {
  1207 		suiteExists = iMetaDataModel->SuiteModelExistsL(
  1236     suiteExists = iMetaDataModel->SuiteModelExistsL(
  1208 			( *suiteNameArray )[i] );
  1237       ( *suiteNameArray )[i] );
  1209 		TBool nextExists = i < suiteNameArray->Count() - 1 &&
  1238     TBool nextExists = i < suiteNameArray->Count() - 1 &&
  1210 			iMetaDataModel->SuiteModelExistsL( ( *suiteNameArray )[i + 1] );
  1239       iMetaDataModel->SuiteModelExistsL( ( *suiteNameArray )[i + 1] );
  1211 		TBool isLast = ( i == ( suiteNameArray->Count() - 1 ) );
  1240     TBool isLast = ( i == ( suiteNameArray->Count() - 1 ) );
  1212 
  1241 
  1213 		TBool turnOnEvaluation = ( suiteExists && ( !nextExists || isLast ) );
  1242     TBool turnOnEvaluation = ( suiteExists && ( !nextExists || isLast ) );
  1214 		if( turnOnEvaluation || !suiteExists )
  1243     if( turnOnEvaluation || !suiteExists )
  1215 			{
  1244       {
  1216 			iMetaDataModel->IgnoreEvaluations( EFalse );
  1245       iMetaDataModel->IgnoreEvaluations( EFalse );
  1217 			}
  1246       }
  1218 
  1247 
  1219 		TInt err( KErrNone );
  1248     TInt err( KErrNone );
  1220 
  1249 
  1221 		// Ignore loading new suite if the last suite in model is the same
  1250     // Ignore loading new suite if the last suite in model is the same
  1222 		// as first one in the uri.
  1251     // as first one in the uri.
  1223 		if ( i == 0 )
  1252     if ( i == 0 )
  1224 			{
  1253       {
  1225 			if ( SuitesAreTheSameL( iMetaDataModel->GetLastSuite()->SuiteName(), (*suiteNameArray)[i] ) )
  1254       if ( SuitesAreTheSameL( iMetaDataModel->GetLastSuite()->SuiteName(), (*suiteNameArray)[i] ) )
  1226 				{
  1255         {
  1227 				HandleTheSameSuitesL( nextExists, parser.Extract( EUriQuery ) );
  1256         HandleTheSameSuitesL( nextExists, parser.Extract( EUriQuery ) );
  1228 				sendToForeground = ETrue;
  1257         sendToForeground = ETrue;
  1229 				continue;
  1258         continue;
  1230 				}
  1259         }
  1231 			}
  1260       }
  1232 
  1261 
  1233 		if( suiteExists )
  1262     if( suiteExists )
  1234 			{
  1263       {
  1235 			if (!nextExists)
  1264       if (!nextExists)
  1236 			    {
  1265           {
  1237 			    // Tricky: queue foreground so that if the suite is evaluated synchronously
  1266           // Tricky: queue foreground so that if the suite is evaluated synchronously
  1238 			    // the foreground will be gained.
  1267           // the foreground will be gained.
  1239 			    iMetaDataModel->QueueForeground( CHnMdModel::EWhenAnySuiteIsEvaluated );
  1268           iMetaDataModel->QueueForeground( CHnMdModel::EWhenAnySuiteIsEvaluated );
  1240 			    }
  1269           }
  1241 			err = LoadSuiteFromUriL(
  1270       err = LoadSuiteFromUriL(
  1242 				( *suiteNameArray )[i], parser.Extract( EUriQuery ), parser.Extract( EUriFragment ) );
  1271         ( *suiteNameArray )[i], parser.Extract( EUriQuery ), parser.Extract( EUriFragment ) );
  1243 			if ( KErrNone == err && !nextExists && iMetaDataModel->IsForegroundQueued() )
  1272       if ( KErrNone == err && !nextExists && iMetaDataModel->IsForegroundQueued() )
  1244 			    {
  1273           {
  1245 			    // Tricky: if foreground is still queued it means that the suite is evaluated
  1274           // Tricky: if foreground is still queued it means that the suite is evaluated
  1246 			    // asynchronously. Override the previos foreground queue setting with one
  1275           // asynchronously. Override the previos foreground queue setting with one
  1247 			    // that will be effective only if the last loaded suite is evaluated.
  1276           // that will be effective only if the last loaded suite is evaluated.
  1248 			    iMetaDataModel->QueueForeground( CHnMdModel::EWhenCurrentTopSuiteIsEvaluated );
  1277           iMetaDataModel->QueueForeground( CHnMdModel::EWhenCurrentTopSuiteIsEvaluated );
  1249 			    }
  1278           }
  1250 			if ( err != KErrNone )
  1279       if ( err != KErrNone )
  1251 				{
  1280         {
  1252 				sendToForeground = ETrue;
  1281         sendToForeground = ETrue;
  1253 				}
  1282         }
  1254 			}
  1283       }
  1255 
  1284 
  1256 		if( !suiteExists || err != KErrNone || !nextExists )
  1285     if( !suiteExists || err != KErrNone || !nextExists )
  1257 			{
  1286       {
  1258 			CHnFilter* filter = CHnFilter::NewLC();
  1287       CHnFilter* filter = CHnFilter::NewLC();
  1259 
  1288 
  1260 			filter->SetSuiteId(
  1289       filter->SetSuiteId(
  1261 				iSuiteContainer->GetLastSuiteModel()->CustomId() );
  1290         iSuiteContainer->GetLastSuiteModel()->CustomId() );
  1262 
  1291 
  1263 			filter->SetEvaluateSuiteL( ETrue );
  1292       filter->SetEvaluateSuiteL( ETrue );
  1264 			iMetaDataModel->IgnoreEvaluations( EFalse );
  1293       iMetaDataModel->IgnoreEvaluations( EFalse );
  1265 
  1294 
  1266 			TRAPD( err, iMetaDataModel->EvaluateL( *filter ) );
  1295       TRAPD( err, iMetaDataModel->EvaluateL( *filter ) );
  1267 
  1296 
  1268 			CleanupStack::PopAndDestroy( filter );
  1297       CleanupStack::PopAndDestroy( filter );
  1269 			if( err )
  1298       if( err )
  1270 				{
  1299         {
  1271 				iMetaDataModel->DeleteLastSuite();
  1300         iMetaDataModel->DeleteLastSuite();
  1272 				iSuiteContainer->PopSuiteModelL(
  1301         iSuiteContainer->PopSuiteModelL(
  1273 					 HnConvUtils::Str8ToStr( ( *suiteNameArray )[i] )->Des() );
  1302            HnConvUtils::Str8ToStr( ( *suiteNameArray )[i] )->Des() );
  1274 				sendToForeground = ETrue;
  1303         sendToForeground = ETrue;
  1275 				}
  1304         }
  1276 			break;
  1305       break;
  1277 			}
  1306       }
  1278 		}
  1307     }
  1279 
  1308 
  1280 	// set highlight only when path is valid!
  1309   // set highlight only when path is valid!
  1281 	if( suiteExists )
  1310   if( suiteExists )
  1282 		{
  1311     {
  1283 		HighlightPlacementFromUriL( parser.Extract( EUriFragment ) );
  1312     HighlightPlacementFromUriL( parser.Extract( EUriFragment ) );
  1284 		}
  1313     }
  1285 
  1314 
  1286     CleanupStack::PopAndDestroy( &host8 );
  1315     CleanupStack::PopAndDestroy( &host8 );
  1287 	CleanupStack::PopAndDestroy( suiteNameArray );
  1316   CleanupStack::PopAndDestroy( suiteNameArray );
  1288 	CleanupStack::PopAndDestroy( uriBuf );
  1317   CleanupStack::PopAndDestroy( uriBuf );
  1289 
  1318 
  1290 //    send to foreground
  1319 //    send to foreground
  1291 	if ( sendToForeground )
  1320   if ( sendToForeground )
  1292 		{
  1321     {
  1293 		CLiwGenericParamList* pl = CLiwGenericParamList::NewL();
  1322     CLiwGenericParamList* pl = CLiwGenericParamList::NewL();
  1294 		CleanupStack::PushL( pl );
  1323     CleanupStack::PushL( pl );
  1295 		HandleModelEventL( KAppGainForeground, *pl );
  1324     HandleModelEventL( KAppGainForeground, *pl );
  1296 		CleanupStack::PopAndDestroy( pl );
  1325     CleanupStack::PopAndDestroy( pl );
  1297 		iMetaDataModel->QueueForeground( CHnMdModel::ENever );
  1326     iMetaDataModel->QueueForeground( CHnMdModel::ENever );
  1298 		}
  1327     }
  1299 
  1328 
  1300 	}
  1329   }
  1301 
  1330 
  1302 // End of file
  1331 // End of file