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