searchui/searchapp/plugins/resultviewerplugin/src/srchuiresultview.cpp
changeset 0 f979ecb2b13e
child 5 42814f902fe6
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:     This class is responsible for the display of the results in snippets for a particular content class selected by the user. 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // System Includes
       
    24 #include <eikmenup.h>
       
    25 #include <srchuiresultview.rsg>
       
    26 #include <StringLoader.h>
       
    27 #include <FileManager.rsg>
       
    28 #include <data_caging_path_literals.hrh>
       
    29 #include <bautils.h>
       
    30 #include <searchdocumentid.h>
       
    31 #include <utf.h>
       
    32 #include <apgcli.h>
       
    33 #include <aknnotewrappers.h>
       
    34 #include <bautils.h>
       
    35 #include <filessearchresource.rsg>
       
    36 #include <bautils.h>
       
    37 #include <e32debug.h>
       
    38 #include <DocumentHandler.h>
       
    39 #include <AknServerApp.h>
       
    40 #include <w32std.h>
       
    41 #include <hlplch.h> // help launcher
       
    42 #include <csxhelp/search.hlp.hrh>
       
    43 
       
    44 // User Includes
       
    45 #include "srchuiresfolder.h"
       
    46 #include "srchuiresultview.h"
       
    47 #include "srchuiresultcontainer.h"
       
    48 #include "srchuiresultviewuids.h"
       
    49 #include "srchuiresult.hrh"
       
    50 #include "srchuiresultviewdefines.h"
       
    51 
       
    52 #include<ccafactory.h>
       
    53 #include<mccaparameter.h>
       
    54 #include<mccaconnection.h>
       
    55 
       
    56 #define KSearchFileUid 0x10282400
       
    57 #define KSearchContact 0x102823FE   //Plug-in uid ,using in launch a contact with new API
       
    58 // =========================== MEMBER FUNCTIONS ===============================
       
    59 
       
    60 // ----------------------------------------------------------------------------
       
    61 // CSrchUiResultView::NewL
       
    62 // Symbian OS 2 phased constructor.
       
    63 // ----------------------------------------------------------------------------
       
    64 //
       
    65 CSrchUiResultView* CSrchUiResultView::NewL()
       
    66 	{
       
    67     CSrchUiResultView* self = CSrchUiResultView::NewLC();
       
    68     CleanupStack::Pop( self );
       
    69     return self;
       
    70 	}
       
    71 
       
    72 // ----------------------------------------------------------------------------
       
    73 // CSrchUiResultView::NewLC
       
    74 // Symbian OS 2 phased constructor.
       
    75 // ----------------------------------------------------------------------------
       
    76 //
       
    77 CSrchUiResultView* CSrchUiResultView::NewLC()
       
    78 	{
       
    79     CSrchUiResultView* self = new ( ELeave ) CSrchUiResultView();
       
    80     CleanupStack::PushL( self );
       
    81     self->ConstructL();
       
    82     return self;
       
    83 	}
       
    84 
       
    85 // ----------------------------------------------------------------------------
       
    86 // CSrchUiResultView::~CSearchContainer
       
    87 // Destructor.
       
    88 // ----------------------------------------------------------------------------
       
    89 //
       
    90 CSrchUiResultView::~CSrchUiResultView()
       
    91     {
       
    92 	if( iContainer )
       
    93 		{
       
    94 		delete iContainer;
       
    95 		iContainer = NULL;
       
    96 		}
       
    97 
       
    98 	if( iQueryString )
       
    99 		{
       
   100 		delete iQueryString;
       
   101 		iQueryString = NULL;
       
   102 		}
       
   103 
       
   104 	for(TInt i = 0; i < iResFileOffset.Count(); i++)
       
   105 	    {
       
   106 	    iSrchEikonEnv->DeleteResourceFile(iResFileOffset[i]);			
       
   107 	    }
       
   108 	    
       
   109 	if(iPeriodicTimer)
       
   110 	{
       
   111 	    iPeriodicTimer->Cancel();
       
   112 	    delete iPeriodicTimer;
       
   113 	    iPeriodicTimer = NULL;
       
   114 	}
       
   115 	
       
   116 	iResFileOffset.Reset();
       
   117     if( iHandler )
       
   118     	{
       
   119     	delete iHandler;
       
   120     	iHandler = NULL;
       
   121     	}
       
   122     
       
   123     if( iConnection )
       
   124     	{
       
   125     	iConnection->Close();
       
   126     	}
       
   127     }
       
   128 
       
   129 // ----------------------------------------------------------------------------
       
   130 // CSrchUiResultView::ResultsAddedL
       
   131 // Called from the application ui class when results were added.
       
   132 // ----------------------------------------------------------------------------
       
   133 //
       
   134 void CSrchUiResultView::ResultsAddedL()
       
   135 	{
       
   136 	if ( iContainer )
       
   137 	    {
       
   138         iContainer->ResultsAddedL();
       
   139 	    }
       
   140 	}
       
   141 
       
   142 // ----------------------------------------------------------------------------
       
   143 // CSrchUiResultView::ResultsClearedL
       
   144 // Called from the application ui class when the previous results were deleted.
       
   145 // ----------------------------------------------------------------------------
       
   146 //
       
   147 void CSrchUiResultView::ResultsClearedL()
       
   148     {
       
   149     SetContainerListBoxIndex( KErrNotFound );
       
   150 	if ( iContainer )
       
   151 	    {
       
   152         iContainer->ResultsClearedL();
       
   153 	    }
       
   154     }
       
   155 
       
   156 // ----------------------------------------------------------------------------
       
   157 // CSrchUiResultView::SearchStatusChangedL
       
   158 // Called from the application ui class after some search status change.
       
   159 // ----------------------------------------------------------------------------
       
   160 //
       
   161 void CSrchUiResultView::SearchStatusChangedL()
       
   162     {
       
   163     
       
   164    	if ( iContainer )
       
   165 	    {
       
   166         iContainer->SearchStatusChangedL();
       
   167 	    }
       
   168 	    
       
   169     }
       
   170 
       
   171 // ----------------------------------------------------------------------------
       
   172 // CSrchUiResultView::SearchFinishedL
       
   173 // Called from the application ui class after the search has finished.
       
   174 // ----------------------------------------------------------------------------
       
   175 //
       
   176 void CSrchUiResultView::SearchFinishedL()
       
   177     {
       
   178    	if ( iContainer )
       
   179 	    {
       
   180         iContainer->SearchFinishedL();
       
   181 	    }
       
   182     }
       
   183 
       
   184 // ----------------------------------------------------------------------------
       
   185 // CSrchUiResultView::SetContainerListBoxIndex
       
   186 // Setter for iContainerListBoxIndex.
       
   187 // ----------------------------------------------------------------------------
       
   188 //
       
   189 void CSrchUiResultView::SetContainerListBoxIndex( TInt aIndex )
       
   190     {
       
   191     iContainerListBoxIndex = aIndex;
       
   192     }
       
   193 
       
   194 // ----------------------------------------------------------------------------
       
   195 // CSrchUiResultView::ContainerListBoxIndex
       
   196 // Getter for iContainerListBoxIndex.
       
   197 // ----------------------------------------------------------------------------
       
   198 //
       
   199 TInt CSrchUiResultView::ContainerListBoxIndex()    
       
   200     {
       
   201     return iContainerListBoxIndex;
       
   202     }
       
   203 
       
   204 // ----------------------------------------------------------------------------
       
   205 // CSrchUiResultView::UpdateCommandButtons
       
   206 // This function updates the Command buttons when called from container
       
   207 // when tabbed
       
   208 // ----------------------------------------------------------------------------
       
   209 //
       
   210 void CSrchUiResultView::UpdateCommandButtonsL( TInt aResultCount ) 
       
   211 	{
       
   212 	if ( Cba() ) 
       
   213 		{
       
   214 		if ( iResHandler->IsSearching() )
       
   215 			{
       
   216 
       
   217 			Cba()->SetCommandSetL(R_SOFTKEYS_OPTIONS_MSKEMPTY_CANCEL);
       
   218 				
       
   219 			}
       
   220 		else 
       
   221 			{
       
   222 			if ( !aResultCount ) 
       
   223 				{
       
   224 				Cba()->SetCommandSetL( R_SOFTKEYS_OPTIONS_MSKEMPTY_BACK );		
       
   225 				}
       
   226 			else 
       
   227 				{
       
   228 				Cba()->SetCommandSetL( R_SOFTKEYS_OPTIONS_OPEN_BACK );		
       
   229 				}	
       
   230 			}
       
   231 		
       
   232 		Cba()->DrawDeferred();	
       
   233 		}
       
   234 	
       
   235 	
       
   236 	}
       
   237 	
       
   238 // ----------------------------------------------------------------------------
       
   239 // CSrchUiResultView::SupportedFormat
       
   240 // Getter for supported format
       
   241 // ----------------------------------------------------------------------------
       
   242 //
       
   243 const TDesC& CSrchUiResultView::SupportedFormat()
       
   244 	{
       
   245     return KSrchUiResultViewerSupportsText;
       
   246 	}
       
   247 
       
   248 // ----------------------------------------------------------------------------
       
   249 // CSrchUiResultView::HandleSelectionL
       
   250 // called when one of the results is selected. 
       
   251 // ----------------------------------------------------------------------------
       
   252 //
       
   253 void CSrchUiResultView::HandleSelectionL(const CSearchDocumentId& aDocumentId )
       
   254 	{
       
   255     if(iOpenedFolder->GetHeavyResultsCount()>0)
       
   256         {
       
   257         TInt selectedItemId = aDocumentId.PluginId().iUid ;
       
   258         if( selectedItemId == KSearchFileUid )
       
   259     	    {
       
   260     	    HBufC8* launchInfo = iResHandler->GetLaunchInfoL(aDocumentId);
       
   261     	    LaunchApplicationL( *launchInfo );
       
   262     	    if( launchInfo )
       
   263     		    {
       
   264     		    delete launchInfo;
       
   265     		    launchInfo = NULL;
       
   266     		    }
       
   267     	    return;
       
   268     	    }
       
   269 		//new add ,using launch a contact with new API	
       
   270         if( selectedItemId == KSearchContact )
       
   271         	{
       
   272         	HBufC8* launchInfo = iResHandler->GetLaunchInfoL(aDocumentId);
       
   273         	LaunchContactApplicationL( *launchInfo );
       
   274 			if( launchInfo )
       
   275 				{
       
   276 				delete launchInfo;
       
   277 				launchInfo = NULL;
       
   278 				}
       
   279         	return ;
       
   280         	}
       
   281 			
       
   282         iResHandler->LaunchApplicationL( aDocumentId );   
       
   283         }
       
   284 	}
       
   285 
       
   286 // ----------------------------------------------------------------------------
       
   287 // CSrchUiResultView::OpenFolder
       
   288 // called when one of the results is selected. 
       
   289 // ----------------------------------------------------------------------------
       
   290 //
       
   291 MSrchUiFolder* CSrchUiResultView::OpenFolder()
       
   292 	{
       
   293     //  return STATIC_CAST( MSrchUiFolder*, iOpenedFolder );
       
   294     //to be implemented
       
   295     return NULL;
       
   296 	}
       
   297 
       
   298 // ----------------------------------------------------------------------------
       
   299 // CSrchUiResultView::GetQueryString
       
   300 // This function is called to get the query string
       
   301 // ----------------------------------------------------------------------------
       
   302 //
       
   303 TDesC8& CSrchUiResultView::GetQueryString()
       
   304 	{
       
   305 	return(*iQueryString);
       
   306 	}
       
   307 
       
   308 // ----------------------------------------------------------------------------
       
   309 // CSrchUiResultView::Id
       
   310 // Returns the unique id of the view.
       
   311 // ----------------------------------------------------------------------------
       
   312 //
       
   313 TUid CSrchUiResultView::Id() const
       
   314     {
       
   315     return KSearchResultViewUid;
       
   316     }
       
   317 
       
   318 // ----------------------------------------------------------------------------
       
   319 // CSrchUiResultView::HandleCommandL
       
   320 // Handles the commands that are passed from softkey generated commands and
       
   321 // pop up's.
       
   322 // ----------------------------------------------------------------------------
       
   323 //
       
   324 void CSrchUiResultView::HandleCommandL( TInt aCommand )
       
   325     {
       
   326     switch ( aCommand )
       
   327         {
       
   328         case ESearchCmdOpen:
       
   329             if(iOpenedFolder->GetHeavyResultsCount()>0)
       
   330             {
       
   331                 TInt selectedItemId = iContainer->HandleItemSelectionL().PluginId().iUid ;
       
   332                 if( selectedItemId == KSearchFileUid )
       
   333             	    {
       
   334             	    HBufC8* launchInfo = iResHandler->GetLaunchInfoL(iContainer->HandleItemSelectionL());
       
   335             	    LaunchApplicationL( *launchInfo );
       
   336             	    if( launchInfo )
       
   337             		    {
       
   338             		    delete launchInfo;
       
   339             		    launchInfo = NULL;
       
   340             		    }
       
   341             	    break;
       
   342             	    }
       
   343 					
       
   344                 if( selectedItemId == KSearchContact )
       
   345 					{
       
   346 					HBufC8* launchInfo = iResHandler->GetLaunchInfoL( iContainer->HandleItemSelectionL() );
       
   347 					LaunchContactApplicationL( *launchInfo );
       
   348 					if( launchInfo )
       
   349 						{
       
   350 						delete launchInfo;
       
   351 						launchInfo = NULL;
       
   352 						}
       
   353 					break ; 
       
   354 					}
       
   355 										
       
   356              iResHandler->LaunchApplicationL( iContainer->HandleItemSelectionL() );   
       
   357             }
       
   358              
       
   359             break;
       
   360 
       
   361         case ESearchCmdSearch:
       
   362         	{
       
   363         	 iResHandler->StartNewSearchL();	
       
   364         	}
       
   365         	break;
       
   366         	
       
   367          case ESearchCmdSettings:
       
   368         	{
       
   369         		
       
   370         	}
       
   371         	break;
       
   372          case ESearchCmdHelp:
       
   373         	{
       
   374         	TCoeHelpContext helpContext;
       
   375         	helpContext.iMajor = KSearchAppUid ;
       
   376         	helpContext.iContext = KSEARCH_HLP_SINGLE_RE; // add correct help context when available
       
   377         	CArrayFix<TCoeHelpContext>* hlpContextArray = 
       
   378         	                    new ( ELeave ) CArrayFixFlat<TCoeHelpContext> ( 1 );
       
   379         	CleanupStack::PushL( hlpContextArray );
       
   380         	hlpContextArray->AppendL( helpContext );
       
   381         	CleanupStack::Pop( hlpContextArray );
       
   382         	//Launch help - takes ownership of hlpContextArray
       
   383         	HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   384         	                                                 hlpContextArray ); 
       
   385         		
       
   386         	}
       
   387         	break;
       
   388         case EAknSoftkeyCancel:
       
   389         	iResHandler->CancelSearch();
       
   390        	break;
       
   391         case EAknSoftkeyBack:
       
   392             iResHandler->LaunchPreviousViewL();
       
   393             break;
       
   394             //Do nothing(Ignoring)
       
   395         case EAknSoftkeyEmpty:
       
   396         	break;
       
   397         default:
       
   398 			((CAknAppUi*)iSrchEikonEnv->EikAppUi())->HandleCommandL( aCommand );
       
   399 			break;
       
   400         }
       
   401     }
       
   402 
       
   403 // ----------------------------------------------------------------------------
       
   404 // CSrchUiResultView::DoActivateL
       
   405 // Called by the framework when the view is activated.
       
   406 // ----------------------------------------------------------------------------
       
   407 //
       
   408 void CSrchUiResultView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
       
   409                   TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/ )
       
   410     {
       
   411     if ( !iContainer )
       
   412         {
       
   413         
       
   414         
       
   415         
       
   416         iContainer = new( ELeave )CSrchUiResultContainer( *this );
       
   417 		iContainer->SetMopParent( this );
       
   418 		iContainer->SetRoot(iOpenedFolder);
       
   419 		iContainer->ConstructL( ClientRect(),iSelectedFolderIdx,
       
   420 		                                               iSrchUiResRootFolder );
       
   421 		                                               
       
   422 		iPeriodicTimer = CPeriodic::NewL( CActive::EPriorityHigh );
       
   423     	StartTimer();		                                            
       
   424 		                                               
       
   425 		UpdateViewL(iSrchUiResRootFolder, !iResHandler->IsSearching(), EFalse );
       
   426         ((CAknAppUi*)iSrchEikonEnv->EikAppUi())->AddToStackL( iContainer );
       
   427         iContainer->MakeVisible( ETrue );
       
   428         
       
   429         iContainer->UpdateTitlePaneL();
       
   430         
       
   431         
       
   432         }
       
   433         {
       
   434         	
       
   435 	   if ( Cba() )
       
   436 			{
       
   437 			TInt resultsCount = 0;
       
   438 			iOpenedFolder =  STATIC_CAST( CSrchUiResFolder* ,
       
   439 	                      iSrchUiResRootFolder->GetSubFolder(iSelectedFolderIdx) );
       
   440 			resultsCount = iOpenedFolder->GetHeavyResultsCount();
       
   441 			if ( iResHandler->IsSearching() )
       
   442 				{
       
   443 				Cba()->SetCommandSetL(R_SOFTKEYS_OPTIONS_MSKEMPTY_CANCEL);
       
   444 				}
       
   445 			else
       
   446 				{
       
   447 				if ( !resultsCount ) 
       
   448 					{
       
   449 					Cba()->SetCommandSetL( R_SOFTKEYS_OPTIONS_MSKEMPTY_BACK );		
       
   450 					}
       
   451 				else 
       
   452 					{
       
   453 					Cba()->SetCommandSetL( R_SOFTKEYS_OPTIONS_OPEN_BACK );		
       
   454 					}
       
   455 				}
       
   456 			Cba()->DrawNow();
       
   457 			}
       
   458         }
       
   459 
       
   460     }
       
   461 
       
   462 // ----------------------------------------------------------------------------
       
   463 // CSrchUiResultView::DoDeactivate
       
   464 // Called by the framework when the view is de-activated.
       
   465 // ----------------------------------------------------------------------------
       
   466 //
       
   467 void CSrchUiResultView::DoDeactivate()
       
   468     {
       
   469     if ( iPeriodicTimer && iPeriodicTimer->IsActive() )
       
   470 	    {
       
   471 	    iPeriodicTimer->Cancel();
       
   472 	    delete iPeriodicTimer; 
       
   473 	    iPeriodicTimer = NULL; 
       
   474 	    }
       
   475 	    
       
   476     if ( iContainer )
       
   477 		{
       
   478 		((CAknAppUi*)iSrchEikonEnv->EikAppUi())->RemoveFromStack( iContainer );
       
   479 
       
   480         iContainer->MakeVisible( EFalse );
       
   481 		delete iContainer;
       
   482 		iContainer = NULL;
       
   483 		}
       
   484     }
       
   485 
       
   486 // ----------------------------------------------------------------------------
       
   487 // CSrchUiResultView::DynInitMenuPaneL
       
   488 // Called by the framework for dynamically initializing the menu pane.
       
   489 // ----------------------------------------------------------------------------
       
   490 //
       
   491 void CSrchUiResultView::DynInitMenuPaneL(TInt aResourceId,
       
   492                                                     CEikMenuPane* aMenuPane)
       
   493     {
       
   494     if(!iContainer->IsElementValid())
       
   495         {
       
   496         if ( aResourceId == R_SEARCH_RESULT_VIEW_MENU_PANE )
       
   497             {
       
   498         	aMenuPane->DeleteMenuItem( ESearchCmdOpen );
       
   499             }
       
   500         }
       
   501     }
       
   502 
       
   503 // ----------------------------------------------------------------------------
       
   504 // CSrchUiResultView::LaunchViewL
       
   505 // This function is called to launch the single result view
       
   506 // ----------------------------------------------------------------------------
       
   507 //
       
   508 void CSrchUiResultView::LaunchViewL(CSrchUiResFolder* aSrchUiResRootFolder,
       
   509                            TInt aSelectedFolderIdx, const TDesC8& aQueryString, TBool aSearchFinished)
       
   510 	{
       
   511     iSrchUiResRootFolder = NULL;
       
   512 	iSrchUiResRootFolder = aSrchUiResRootFolder;
       
   513     iOpenedFolder =  STATIC_CAST(CSrchUiResFolder* ,
       
   514                       iSrchUiResRootFolder->GetSubFolder(aSelectedFolderIdx));
       
   515     iSelectedFolderIdx = aSelectedFolderIdx;
       
   516 	TVwsViewId viewid(TUid::Uid(KSearchAppUid.iUid),KSearchResultViewUid);
       
   517 	iSrchEikonEnv->AppUi()->ActivateViewL(viewid);
       
   518     
       
   519     if(iQueryString)
       
   520     {
       
   521         delete(iQueryString);
       
   522         iQueryString = NULL;
       
   523     }
       
   524     iQueryString = aQueryString.AllocL();
       
   525 	}
       
   526 
       
   527 // ----------------------------------------------------------------------------
       
   528 // CSrchUiResultView::IncrementFolderIndex
       
   529 // This function is to increment the selected folders.
       
   530 // ----------------------------------------------------------------------------
       
   531 //
       
   532 void CSrchUiResultView::IncrementFolderIndex() 
       
   533 	{
       
   534 	iSelectedFolderIdx++;
       
   535 	}
       
   536 
       
   537 // ----------------------------------------------------------------------------
       
   538 // CSrchUiResultView::DecrementFolderIndex
       
   539 // This function is to decrement the folder count.
       
   540 // ----------------------------------------------------------------------------
       
   541 //
       
   542 void CSrchUiResultView::DecrementFolderIndex() 
       
   543 	{
       
   544 	iSelectedFolderIdx--;
       
   545 	}	
       
   546 void CSrchUiResultView::UpdateViewL(CSrchUiResFolder* aSrchUiResRootFolder, TBool aSearchFinished, TBool aResultRetrieve)
       
   547 	{
       
   548 	//If incase this function is called, before the view has been activated
       
   549 	//Activate the view
       
   550 	if( !iContainer )
       
   551 		{
       
   552 		return;
       
   553 		}
       
   554            
       
   555             iSrchUiResRootFolder = aSrchUiResRootFolder;
       
   556             if ( Cba() )
       
   557 		{
       
   558 		TInt resultsCount = 0;
       
   559 		iOpenedFolder =  STATIC_CAST(CSrchUiResFolder* ,
       
   560                       iSrchUiResRootFolder->GetSubFolder(iSelectedFolderIdx));
       
   561 		resultsCount = iOpenedFolder->GetHeavyResultsCount();
       
   562 		iSearchFinished = !iResHandler->IsSearching();
       
   563 		if(!aSearchFinished)
       
   564 		{
       
   565 		Cba()->SetCommandSetL( R_SOFTKEYS_OPTIONS_MSKEMPTY_CANCEL );	
       
   566 		}
       
   567 		else
       
   568 		{
       
   569 			if ( !resultsCount ) 
       
   570 				{
       
   571 				Cba()->SetCommandSetL( R_SOFTKEYS_OPTIONS_MSKEMPTY_BACK );		
       
   572 				}
       
   573 			else 
       
   574 				{
       
   575 				Cba()->SetCommandSetL( R_SOFTKEYS_OPTIONS_OPEN_BACK );		
       
   576 				}
       
   577 		}
       
   578 		Cba()->DrawDeferred();
       
   579 		}
       
   580     
       
   581 		if ( iContainer ) 
       
   582 			{
       
   583 			iContainer->UpdateViewL( iSrchUiResRootFolder, 
       
   584 				aSearchFinished, aResultRetrieve );	
       
   585 			}
       
   586     	
       
   587     
       
   588 	    if ( aSearchFinished )
       
   589 	   		
       
   590 	    	{
       
   591 	        // Stop the timer if it is active
       
   592 		    if ( iPeriodicTimer && iPeriodicTimer->IsActive() )
       
   593 		    	{
       
   594 		    	iPeriodicTimer->Cancel();
       
   595 		    	if ( iPeriodicTimer )
       
   596 					{
       
   597 				    delete iPeriodicTimer;
       
   598 				    iPeriodicTimer = NULL;
       
   599 					}
       
   600 		    	}
       
   601 	    	
       
   602 	    	}
       
   603 	    UpdateNaviPaneL();	
       
   604 	}
       
   605 	
       
   606 // ----------------------------------------------------------------------------
       
   607 // CSrchUiResultView::CreateManagerObserver
       
   608 // This function is called to initialize the observer
       
   609 // ----------------------------------------------------------------------------
       
   610 //
       
   611 void CSrchUiResultView::CreateManagerObserver(
       
   612                                       MSrchUiResultHandler* aResHandler )
       
   613 	{
       
   614     iResHandler = aResHandler;
       
   615 	}
       
   616 
       
   617 // ----------------------------------------------------------------------------
       
   618 // CSrchUiResultView::CSrchUiResultView
       
   619 // Performs the first phase of two phase construction.
       
   620 // ----------------------------------------------------------------------------
       
   621 //
       
   622 CSrchUiResultView::CSrchUiResultView()
       
   623 :   iSrchEikonEnv(CEikonEnv::Static())
       
   624 	{
       
   625 	}
       
   626 
       
   627 // ----------------------------------------------------------------------------
       
   628 // CSrchUiResultView::ConstructL
       
   629 // Performs the second phase construction.
       
   630 // ----------------------------------------------------------------------------
       
   631 //
       
   632 void CSrchUiResultView::ConstructL()
       
   633     {
       
   634     iHandler = CDocumentHandler::NewL();
       
   635     TParse* fp = new(ELeave) TParse ();
       
   636 	fp->Set (KSearchResourceFile, &KDC_APP_RESOURCE_DIR, NULL);
       
   637 	TBuf<254> resourceFileName;
       
   638 	resourceFileName.Copy(fp ->FullName());
       
   639 	delete fp;
       
   640 	fp=NULL;
       
   641     
       
   642     TPtrC driveLetter = TParsePtrC( RProcess().FileName() ).Drive();
       
   643     TFileName fileName( driveLetter );
       
   644     fileName.Append( resourceFileName );
       
   645     
       
   646     //TInt offset  = iSrchEikonEnv->AddResourceFileL(KSearchResourceFile); 
       
   647     BaflUtils::NearestLanguageFile( iSrchEikonEnv->FsSession(), fileName  );
       
   648     TInt offset  = iSrchEikonEnv->AddResourceFileL(fileName); 
       
   649     iResFileOffset.Append(offset);		
       
   650     BaseConstructL( R_SEARCH_RESULT_VIEW );
       
   651     
       
   652     ((CAknViewAppUi*)iSrchEikonEnv->EikAppUi())->AddViewL(this);
       
   653 
       
   654 
       
   655     iConnection = TCCAFactory::NewConnectionL();
       
   656 
       
   657     }
       
   658     
       
   659     
       
   660 // -----------------------------------------------------------------------------
       
   661 // CSrchUiResultView::PeriodL
       
   662 // This function is called by the periodic timer.
       
   663 // -----------------------------------------------------------------------------
       
   664 //
       
   665 TInt CSrchUiResultView::PeriodL( TAny* aPtr )
       
   666 	{
       
   667   ( static_cast<CSrchUiResultView*>( aPtr ) )->SetNaviTextL();
       
   668     // Returning a value of TRUE indicates the callback should be done again
       
   669 	return ETrue;
       
   670 	}
       
   671 
       
   672 // -----------------------------------------------------------------------------
       
   673 // CSrchUiResFolderView::SetNaviTextL
       
   674 // Updates the navigation with the text about the staus.
       
   675 // -----------------------------------------------------------------------------
       
   676 //
       
   677 void CSrchUiResultView::SetNaviTextL()
       
   678 {
       
   679 	HBufC16 *pbuf;	
       
   680 	pbuf = StringLoader::LoadL(R_QTN_SEARCH_INPROGRESS);
       
   681 	
       
   682 	HBufC16* tmpbuf = HBufC::NewL( pbuf->Size() + 3 );
       
   683 	TPtr bufPtr = tmpbuf->Des();
       
   684 	bufPtr.Copy( *pbuf );
       
   685 	
       
   686 	
       
   687 	for ( TInt i = 0; i <= iCount_val%3; i++ ) 
       
   688 		{
       
   689 		_LIT ( KDot, "." );
       
   690 		bufPtr.Append( KDot );
       
   691 		}
       
   692 	
       
   693     iCount_val++;
       
   694     
       
   695     if ( iContainer )
       
   696     	{
       
   697         iContainer->UpdateNaviPaneL( *tmpbuf );
       
   698     	}
       
   699     
       
   700     delete pbuf;
       
   701     delete tmpbuf;
       
   702 }
       
   703     
       
   704 // -------------------------------------------------------------------------------------------------
       
   705 // CSrchUiResFolderView::StartTimer
       
   706 // Starts the timer.
       
   707 // -------------------------------------------------------------------------------------------------
       
   708 //    
       
   709 void CSrchUiResultView::StartTimer()
       
   710 	{
       
   711 	// If the timer is not already running, start it
       
   712 	if ( !iPeriodicTimer->IsActive() )
       
   713 		{
       
   714 		iPeriodicTimer->Start( 10, 300000, 
       
   715                                TCallBack( CSrchUiResultView::PeriodL, this ) );
       
   716 		}
       
   717 
       
   718 	}
       
   719     
       
   720     
       
   721 // -------------------------------------------------------------------------------------------------
       
   722 // CSrchUiResultView::UpdateNaviPaneL
       
   723 // Updates the navigation Pane.
       
   724 // -------------------------------------------------------------------------------------------------
       
   725 //
       
   726 void CSrchUiResultView::UpdateNaviPaneL()
       
   727     {
       
   728         if( iResHandler->IsSearching() )
       
   729         {
       
   730         	SetNaviTextL();
       
   731         }
       
   732         else
       
   733         {
       
   734            if ( iContainer ) 
       
   735            	   {
       
   736            	   iContainer->UpdateNaviResultPaneL();
       
   737            	   }
       
   738             
       
   739         }
       
   740        
       
   741         
       
   742     }
       
   743 
       
   744 // -------------------------------------------------------------------------------------------------
       
   745 // CSrchUiResultView::LaunchApplicationL
       
   746 // Launch the app for a file
       
   747 // -------------------------------------------------------------------------------------------------
       
   748 //
       
   749 void CSrchUiResultView::LaunchApplicationL( const TDesC8& aLaunchInfo )
       
   750     {
       
   751 	RFs fs;
       
   752 	User::LeaveIfError( fs.Connect() );
       
   753 	User::LeaveIfError( fs.ShareProtected() );
       
   754 	iHandler->SetExitObserver( this );
       
   755 	TEntry fileEntry;
       
   756 	HBufC *path16 = HBufC::NewL( KMaxFileName ) ;
       
   757 	TPtr docIdPtr = path16->Des();
       
   758 	CnvUtfConverter::ConvertToUnicodeFromUtf8( docIdPtr,aLaunchInfo ) ;
       
   759 	CAiwGenericParamList& paramList( iHandler->InParamListL() );
       
   760 	RWsSession ws;
       
   761         User::LeaveIfError( ws.Connect() );
       
   762 	TFindFile AufFolder(fs);
       
   763 	fs.Entry( *path16, fileEntry );
       
   764 	TBool testPath = BaflUtils::FileExists( fs, *path16 );
       
   765 	RFile file;
       
   766         TInt error(0);
       
   767         TRAP(error, file.Open( fs, docIdPtr, EFileShareReadersOnly ) );
       
   768 	CleanupClosePushL( file );
       
   769 	if ( !( fileEntry.IsDir() ) && testPath  ) 
       
   770 	    {
       
   771 		RApaLsSession session;
       
   772 		if( session.Connect() != KErrNone )
       
   773 	        {
       
   774 			return;
       
   775 			}
       
   776 		 TUid uid;
       
   777 		 TDataType dataType;
       
   778 		 TInt err = session.AppForDocument( *path16, uid, dataType );
       
   779 		 session.Close();
       
   780 		 TDataType datatype/*(Kpng)*/;
       
   781 			
       
   782 		 // open file item with embeded mode
       
   783 		 TInt err1( KErrNone );
       
   784 		 TInt err2( KErrNone );
       
   785 		 TRAP(err1, err2 = iHandler->OpenFileL( file, dataType ););
       
   786 		 if ( err2 == KErrNotSupported || err2 == KMimeNotSupported ||
       
   787 				 err1 == KErrNotSupported || err1 == KMimeNotSupported )
       
   788 				{
       
   789 
       
   790 			   _LIT(KFileMgrFilename,"filemanager.rsc");
       
   791 						RResourceFile resourceFile;
       
   792 						TFileName driveResFilename = TParsePtrC( RProcess().FileName() ).Drive();
       
   793 						driveResFilename.Append(KDC_APP_RESOURCE_DIR);
       
   794 						driveResFilename.Append( KFileMgrFilename);
       
   795 						BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), driveResFilename  );
       
   796 						resourceFile.OpenL(CCoeEnv::Static()->FsSession(), driveResFilename );
       
   797 						resourceFile.ConfirmSignatureL(0);
       
   798 						
       
   799 						HBufC8* readBuffer=resourceFile.AllocReadLC( R_QTN_FMGR_ERROR_UNSUPPORT );
       
   800 						const TPtrC16 ptrReadBuffer(( TText16*) readBuffer->Ptr(),
       
   801 													( readBuffer->Length()+1 )>>1 );
       
   802 													
       
   803 						CAknErrorNote* note = new ( ELeave ) CAknErrorNote (ETrue);
       
   804 						note->ExecuteLD( ptrReadBuffer.AllocLC()->Des() );
       
   805 						CleanupStack::PopAndDestroy(2);
       
   806 						resourceFile.Close();
       
   807 				}
       
   808 		 CleanupStack::PopAndDestroy( &file );
       
   809 		 }
       
   810     fs.Close();
       
   811 	ws.Close();
       
   812 	if( path16 )
       
   813 		{
       
   814 		delete path16;
       
   815 		path16 = NULL;
       
   816 		}
       
   817 	}
       
   818 	
       
   819 // -------------------------------------------------------------------------------------------------
       
   820 // CSrchUiResultView::LaunchContactApplicationL
       
   821 // Open a contact with new API
       
   822 // -------------------------------------------------------------------------------------------------
       
   823 //
       
   824 void CSrchUiResultView::LaunchContactApplicationL( const TDesC8& aLaunchInfo )
       
   825 	{
       
   826 
       
   827 	MCCAParameter* parameter = TCCAFactory::NewParameterL();
       
   828 	CleanupClosePushL( *parameter );
       
   829 	
       
   830 	parameter->SetConnectionFlag(MCCAParameter::ENormal);
       
   831 	parameter->SetContactDataFlag(MCCAParameter::EContactLink);
       
   832 	
       
   833 	HBufC* buf=HBufC::NewLC(aLaunchInfo.Length());
       
   834 	buf->Des().Copy(aLaunchInfo);
       
   835 
       
   836 	parameter->SetContactDataL(*buf);
       
   837 	CleanupStack::PopAndDestroy();
       
   838  	 
       
   839 	iConnection->LaunchAppL( *parameter );
       
   840 	
       
   841 	CleanupStack::Pop(); //param
       
   842 
       
   843 	}
       
   844 // End of File