uiservicetab/vimpstengine/src/cvimpstenginesearchmgrextention.cpp
changeset 15 81eeb8c83ce5
parent 0 5e5d6b214f4f
equal deleted inserted replaced
0:5e5d6b214f4f 15:81eeb8c83ce5
     1 /*
       
     2 * Copyright (c) 2008 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: Search manager extension for CVIMPSTEngine
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "cvimpstenginesearchmgrextention.h"
       
    20 
       
    21 #include <ximpcontext.h>
       
    22 #include <ximpcontextobserver.h>
       
    23 #include <presenceobjectfactory.h>
       
    24 #include <ximpidentity.h>
       
    25 #include <ximpobjectfactory.h>
       
    26 #include <ximprequestcompleteevent.h>
       
    27 #include <ximpstatus.h>
       
    28 
       
    29 
       
    30 #include "cvimpstenginerequestmapper.h"
       
    31 #include "cvimpstenginerequest.h"
       
    32 #include "vimpstdebugprint.h"
       
    33 
       
    34 #include "vimpstallerrors.h"
       
    35 #include "tvimpstconsts.h"
       
    36 
       
    37 #include <search.h>
       
    38 #include <searchfeature.h>
       
    39 #include <searchobjectfactory.h>
       
    40 #include <searchelement.h>
       
    41 #include <searchkeysevent.h>
       
    42 #include <searchkeyinfo.h>
       
    43 #include <searchinfo.h>
       
    44 #include <searchevent.h>
       
    45 
       
    46 #include "mvimpstenginesearchextentioneventobserver.h"
       
    47 #include "vimpstdebugtrace.h"
       
    48 
       
    49 
       
    50 
       
    51 // ================= MEMBER FUNCTIONS =======================
       
    52 // ---------------------------------------------------------
       
    53 // CVIMPSTEngineSearchMgrExtention::NewL
       
    54 // Two-phased constructor.
       
    55 // ---------------------------------------------------------
       
    56 CVIMPSTEngineSearchMgrExtention* CVIMPSTEngineSearchMgrExtention::NewL(	
       
    57 							MXIMPContext& aPresenceCtx,						
       
    58 							CVIMPSTEngineRequestMapper& aRequestMapper)
       
    59     {
       
    60     TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::NewL start"));
       
    61     CVIMPSTEngineSearchMgrExtention* self = 
       
    62     			CVIMPSTEngineSearchMgrExtention::NewLC(
       
    63     											aPresenceCtx, 
       
    64     											aRequestMapper
       
    65     										    );
       
    66     CleanupStack::Pop( self );
       
    67    	TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::NewL end"));
       
    68     return self;
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------
       
    72 // CVIMPSTEngineSearchMgrExtention::NewLC
       
    73 // Two-phased constructor.
       
    74 // ---------------------------------------------------------
       
    75 CVIMPSTEngineSearchMgrExtention* CVIMPSTEngineSearchMgrExtention::NewLC(
       
    76 							MXIMPContext& aPresenceCtx,
       
    77 							CVIMPSTEngineRequestMapper& aRequestMapper)
       
    78 	{
       
    79 	TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::NewLC start"));
       
    80 	CVIMPSTEngineSearchMgrExtention* self = new (ELeave) 
       
    81 					CVIMPSTEngineSearchMgrExtention(aPresenceCtx, aRequestMapper);
       
    82 	CleanupStack::PushL( self );
       
    83 	self->ConstructL();
       
    84 	TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::NewLC end"));
       
    85 	return self;
       
    86 	}
       
    87     
       
    88 // ---------------------------------------------------------
       
    89 // CVIMPSTEngineSearchMgrExtention::ConstructL
       
    90 // ---------------------------------------------------------
       
    91 void CVIMPSTEngineSearchMgrExtention::ConstructL()
       
    92 	{
       
    93 	TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::ConstructL start"));
       
    94 
       
    95 	// ximp search plugin
       
    96     iSearchFeature = MSearchFeature::NewL(&iPresenceCtx); 
       
    97     
       
    98 	iSearch = &iSearchFeature->Search();
       
    99 	
       
   100 	iAlreadySubscibed = EFalse;
       
   101 	
       
   102     TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::ConstructL end") );    	
       
   103 		
       
   104     }
       
   105 	
       
   106 // ---------------------------------------------------------
       
   107 // CVIMPSTEngineSearchMgrExtention::CVIMPSTEngineSearchMgrExtention
       
   108 // ---------------------------------------------------------	
       
   109 CVIMPSTEngineSearchMgrExtention::CVIMPSTEngineSearchMgrExtention( MXIMPContext& aPresenceCtx,											
       
   110 											CVIMPSTEngineRequestMapper& aRequestMapper)
       
   111 	:iPresenceCtx(aPresenceCtx),
       
   112 	iRequestMapper(aRequestMapper),
       
   113 	iSearchSupported(TVIMPSTEnums::ESupportUnKnown)
       
   114 	{
       
   115 		
       
   116 	}
       
   117 
       
   118 // ---------------------------------------------------------
       
   119 // CVIMPSTEngineSearchMgrExtention::~CVIMPSTEngineSearchMgrExtention
       
   120 // ---------------------------------------------------------
       
   121 CVIMPSTEngineSearchMgrExtention::~CVIMPSTEngineSearchMgrExtention()
       
   122     {
       
   123     TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::~CVIMPSTEngineSearchMgrExtention start"));    
       
   124     
       
   125 	iSearchObservers.Reset();
       
   126 	delete iSearchFeature;	
       
   127 	iSearchFeature = NULL;
       
   128     
       
   129     TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::~CVIMPSTEngineSearchMgrExtention end"));
       
   130     }
       
   131 
       
   132 
       
   133 // ---------------------------------------------------------
       
   134 // CVIMPSTEngineSearchMgrExtention::SearchContactsL
       
   135 // ---------------------------------------------------------
       
   136 TInt CVIMPSTEngineSearchMgrExtention::SearchContactsL( RArray<TVIMPSTSearchKeyData>& aKeyDataArray )
       
   137 	{
       
   138 	TRACE( T_LIT( "CVIMPSTEngineSearchMgrExtention::SearchContactsL Start" ) );
       
   139 	
       
   140 	TInt err = KErrNotSupported;
       
   141 	if (iSearchSupported == TVIMPSTEnums::ESupported)
       
   142 		{
       
   143 			
       
   144 		TInt keydataCount = aKeyDataArray.Count();
       
   145 		
       
   146 		MXIMPObjectFactory& objFactory = iPresenceCtx.ObjectFactory();
       
   147 		MSearchObjectFactory& searchObjFact= iSearchFeature->SearchObjectFactory();
       
   148 		
       
   149 		MXIMPIdentity* searchId = objFactory.NewIdentityLC();
       
   150 		searchId->SetIdentityL(_L("SEARCH"));
       
   151 		
       
   152 		RPointerArray< MSearchElement > searchList;
       
   153 		CleanupClosePushL( searchList );
       
   154 		
       
   155 		for( TInt i = 0; i<keydataCount; i++  )
       
   156 			{
       
   157 			MXIMPIdentity* searchKeyId = objFactory.NewIdentityLC();
       
   158 			TVIMPSTSearchKeyData data = (aKeyDataArray)[i];
       
   159 			searchKeyId->SetIdentityL( data.iSearchKeyData );	
       
   160 			
       
   161 			MSearchElement* srchElement = searchObjFact.NewSearchElementLC();
       
   162 			if( data.iSearchKey != TVIMPSTEnums::EVIMPSTSearchKeyUknown )
       
   163 				{
       
   164 				srchElement->SetRequestL( *searchKeyId, ConverttoTSearchKey( data.iSearchKey ) );	
       
   165 				}
       
   166 	    	else
       
   167 		    	{
       
   168 		    	MXIMPIdentity* searchLabel = objFactory.NewIdentityLC();	
       
   169 		    	searchLabel->SetIdentityL( data.iSearchLabel );
       
   170 		    	srchElement->SetRequestL( *searchKeyId, *searchLabel );
       
   171 		    	CleanupStack::PopAndDestroy ();//searchLabel
       
   172 		    	}
       
   173 			searchList.Append(srchElement);
       
   174 			
       
   175 			CleanupStack::Pop();//srchElement
       
   176 			CleanupStack::PopAndDestroy();//searchKeyId
       
   177 				
       
   178 			}
       
   179 		
       
   180 		
       
   181 		TXIMPRequestId reqId = iSearch->SearchL(*searchId,searchList,KMaxSearchLimit );
       
   182 		
       
   183 		iRequestMapper.CreateRequestL(reqId, ETrue,EVIMPSTXimpOperationSearchContact);// waite here
       
   184 		
       
   185 		CleanupStack::Pop()	; // searchList
       
   186 		searchList.ResetAndDestroy();//	searchList
       
   187 		CleanupStack::PopAndDestroy ();//searchId 
       
   188 		
       
   189 		TRACE( T_LIT( "CVIMPSTEngineSearchMgrExtention::SearchContactsL End " ) );
       
   190 		err = iReqResult;
       
   191 		}
       
   192 
       
   193 	return err;
       
   194 	}
       
   195 	
       
   196 
       
   197 // -----------------------------------------------------------------------------
       
   198 // CVIMPSTEngineSearchMgrExtention::SubscribeForSearchKeysL()
       
   199 // -----------------------------------------------------------------------------
       
   200 //
       
   201 TInt CVIMPSTEngineSearchMgrExtention::SubscribeForSearchKeysL()
       
   202 	{
       
   203 	TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::SubscribeForSearchKeysL Start"));
       
   204     TRACE( T_LIT( "--> SubscribeForSearchKeysL:iSearchSupported: %d" ), iSearchSupported );
       
   205     TRACE( T_LIT( "--> SubscribeForSearchKeysL: iAlreadySubscibed: %d" ), iAlreadySubscibed );    
       
   206 		
       
   207 	if ( (iSearchSupported == TVIMPSTEnums::ENotSupported) || iAlreadySubscibed )
       
   208 		{
       
   209 		TRACE( T_LIT( "--> SubscribeForSearchKeysL: inside if " ));    
       
   210 		return KErrNone;	
       
   211 		}
       
   212 
       
   213 	if( iSearch )
       
   214 		{
       
   215 	    TRACE( T_LIT( "--> SubscribeForSearchKeysL: inside if(iSearch) " ));    
       
   216 
       
   217 		iAlreadySubscibed = ETrue;
       
   218 		
       
   219 		TXIMPRequestId reqId = iSearch->GetSearchKeysL();			
       
   220 		TRACE( T_LIT( "--> SubscribeForSearchKeysL: iSearch->GetSearchKeysL() " ));    
       
   221 
       
   222 		iRequestMapper.CreateRequestL(reqId, ETrue ,EVIMPSTXimpOperationSubscribeSearchKeys);// waite here
       
   223 		}
       
   224 	
       
   225 	if( ( iReqResult != KPREQUESTERRSUCCESSFUL ) && ( iReqResult != KErrNone ) )
       
   226 		{
       
   227 		iSearchSupported = TVIMPSTEnums::ENotSupported;
       
   228 		}
       
   229 	else
       
   230 	    {
       
   231 	    iSearchSupported = TVIMPSTEnums::ESupported;
       
   232 	    }
       
   233 
       
   234 	TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::SubscribeForSearchKeysL end "));
       
   235 	return iReqResult;;
       
   236 	}	
       
   237 
       
   238 // -----------------------------------------------------------------------------
       
   239 // CVIMPSTEngineSearchMgrExtention::IsSupported()
       
   240 // -----------------------------------------------------------------------------
       
   241 //
       
   242 TVIMPSTEnums::FeatureSupport CVIMPSTEngineSearchMgrExtention::IsSupported() const 
       
   243 	{
       
   244 	return iSearchSupported;
       
   245 	}
       
   246 
       
   247 // ------------------------------------------------------------------------
       
   248 // CVIMPSTEngineSearchMgrExtention::ConverttoTSearchKey
       
   249 // 
       
   250 // ------------------------------------------------------------------------
       
   251 TSearchKey CVIMPSTEngineSearchMgrExtention::ConverttoTSearchKey(TVIMPSTEnums::TVIMPSTSearchKey aKey)
       
   252     {
       
   253     TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::ConverttoTSearchKey start"));
       
   254     
       
   255     TSearchKey ret = EUserFirstName;
       
   256      switch( aKey )
       
   257 		{
       
   258 		case TVIMPSTEnums::EVIMPSTFirstName :
       
   259 			{
       
   260 			ret = EUserFirstName;	        		
       
   261 			break;		
       
   262 			}
       
   263 		case TVIMPSTEnums::EVIMPSTMiddleName :
       
   264 			{
       
   265 			ret = EUserMiddleName ;	        		
       
   266 			break;		
       
   267 			}
       
   268 		case TVIMPSTEnums::EVIMPSTLastName :
       
   269 			{
       
   270 			ret = EUserLastName;	        		
       
   271 			break;		
       
   272 			}
       
   273 		case TVIMPSTEnums::EVIMPSTFullName :
       
   274 			{
       
   275 			ret = EUserFullName;	        		
       
   276 			break;		
       
   277 			}
       
   278 		case TVIMPSTEnums::EVIMPSTCountry :
       
   279 			{
       
   280 			ret = EUserCountry;	        		
       
   281 			break;		
       
   282 			}
       
   283 		case TVIMPSTEnums::EVIMPSTCity :
       
   284 			{
       
   285 			ret = EUserCity;	        		
       
   286 			break;		
       
   287 			}
       
   288 		case TVIMPSTEnums::EVIMPSTEmailAddress :
       
   289 			{
       
   290 			ret = EUserEmailAddress;	        		
       
   291 			break;		
       
   292 			}
       
   293 		case TVIMPSTEnums::EVIMPSTUser :
       
   294 			{
       
   295 			ret = EUser;	        		
       
   296 			break;		
       
   297 			}
       
   298 		case TVIMPSTEnums::EVIMPSTOrganisation :
       
   299 			{
       
   300 			ret = EOrganisation;	        		
       
   301 			break;		
       
   302 			}
       
   303 			
       
   304 		case  TVIMPSTEnums::EVIMPSTNickName  :
       
   305 			{
       
   306 		    ret =  EUserNickName; 		
       
   307 			break;		
       
   308 			}
       
   309 		case TVIMPSTEnums::EVIMPSTState  :
       
   310 			{
       
   311 			ret =  EState; 	 	        		
       
   312 			break;		
       
   313 			}
       
   314 		case  TVIMPSTEnums::EVIMPSTOrganisationUnit  :
       
   315 			{
       
   316 		    ret = EOrganisationUnit;    		
       
   317 			break;		
       
   318 			}
       
   319 		case TVIMPSTEnums::EVIMPSTBirthday :
       
   320 			{
       
   321 		    ret = EBirthday;     		
       
   322 			break;		
       
   323 			}
       
   324 			
       
   325 		default:
       
   326 			{
       
   327 			ret = EUserFirstName ;	
       
   328 			}
       
   329 
       
   330 		} 
       
   331 	
       
   332 	TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::ConverttoTSearchKey end"));
       
   333 	return ret; 
       
   334     }       	
       
   335 
       
   336 
       
   337 // -----------------------------------------------------------------------------
       
   338 // CVIMPSTEngineSearchMgrExtention::Type()
       
   339 // -----------------------------------------------------------------------------
       
   340 //
       
   341 TVIMPSTEnums::ExtentionType CVIMPSTEngineSearchMgrExtention::Type() const
       
   342 	{
       
   343 	return TVIMPSTEnums::ESearch;
       
   344 	}
       
   345 	
       
   346 
       
   347 // ---------------------------------------------------------
       
   348 // CVIMPSTEngineSearchMgrExtention::RegisterObserver
       
   349 // 
       
   350 // ---------------------------------------------------------
       
   351 void CVIMPSTEngineSearchMgrExtention::RegisterObserver(MVIMPSTEngineSearchExtentionEventObserver* aObserver) 
       
   352 	{
       
   353 	TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::RegisterObserver start"));
       
   354 	
       
   355 	TInt index = iSearchObservers.Find(aObserver);
       
   356 	if( index == KErrNotFound )
       
   357 		{
       
   358 		iSearchObservers.Append( aObserver );	
       
   359 		}
       
   360 
       
   361 	TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::RegisterObserver end"));
       
   362     }
       
   363 	
       
   364 // ---------------------------------------------------------
       
   365 // CVIMPSTEngineSearchMgrExtention::UnRegisterObserver
       
   366 // 
       
   367 // ---------------------------------------------------------
       
   368 void  CVIMPSTEngineSearchMgrExtention::UnRegisterObserver(MVIMPSTEngineSearchExtentionEventObserver* aObserver) 
       
   369 	{
       
   370 	TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::UnRegisterObserver start"));
       
   371 	
       
   372 	TInt index = iSearchObservers.Find(aObserver);
       
   373 	
       
   374 	if( index >=0 )
       
   375 		{
       
   376 		iSearchObservers.Remove( index );
       
   377 		iSearchObservers.Compress();
       
   378 		}
       
   379 		
       
   380     TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::UnRegisterObserver end"));
       
   381     }
       
   382     
       
   383 
       
   384 
       
   385 // ---------------------------------------------------------
       
   386 // CVIMPSTEngineSearchMgrExtention::HandleSessionContextEventL
       
   387 // ---------------------------------------------------------
       
   388 void CVIMPSTEngineSearchMgrExtention::HandleSessionContextEventL(const MXIMPContext& /*aContext*/,
       
   389                                                              const MXIMPBase& aEvent,
       
   390                                                              TXimpOperation aXimpOperation/* = EVIMPSTXimpOperationNoOperation*/ )
       
   391     {
       
   392     TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::HandleSessionContextEventL start"));
       
   393     
       
   394     switch( aEvent.GetInterfaceId() )
       
   395         {
       
   396         
       
   397         case MXIMPRequestCompleteEvent::KInterfaceId:
       
   398         	{
       
   399             TRACE( T_LIT("InsideCallbackswitch::MXIMPRequestCompleteEvent"));
       
   400             if ( (EVIMPSTXimpOperationSearchContact == aXimpOperation) 
       
   401              		|| (EVIMPSTXimpOperationSubscribeSearchKeys == aXimpOperation) )
       
   402 	            {            
       
   403 	            const MXIMPRequestCompleteEvent* event =
       
   404 	                TXIMPGetInterface< const MXIMPRequestCompleteEvent >::From( 
       
   405 	                    aEvent, MXIMPBase::EPanicIfUnknown );
       
   406 	            
       
   407 	            iReqResult = event->CompletionResult().ResultCode();
       
   408 	            const TXIMPRequestId& reqId = event->RequestId();
       
   409 	            // Note:FindRequestId does not pass the ownership. hanece req
       
   410 	            // should not be deleted.
       
   411 	            CVIMPSTEngineRequest *req = iRequestMapper.FindRequestId( reqId );                
       
   412 	            
       
   413 	            if ( req )
       
   414 	                {
       
   415 		            req->StopWait() ;   
       
   416 	                iRequestMapper.RemoveRequestId(reqId);
       
   417 	                }
       
   418 	            }
       
   419             break;
       
   420             }
       
   421         
       
   422         case MSearchEvent::KInterfaceId:
       
   423 			{
       
   424 			const MSearchEvent* srchEvent = 
       
   425 			TXIMPGetInterface< const MSearchEvent >::From
       
   426 									(aEvent, MXIMPBase::EPanicIfUnknown);	
       
   427 			TInt count=	srchEvent->SearchResultCount();
       
   428 			const MXIMPIdentity& identity=	srchEvent->SearchId();
       
   429 			TPtrC id=srchEvent->SearchId().Identity();
       
   430 			RArray<TVIMPSTSearchData> resultsArray;
       
   431 			for(TInt i=0;i<count;++i)
       
   432 				{
       
   433 				const MSearchInfo& info=srchEvent->SearchResult(i);
       
   434 				
       
   435 				TVIMPSTSearchData data = 
       
   436 								{
       
   437 								info.GetFieldInfo(EFirstName),
       
   438 								info.GetFieldInfo(ELastName),
       
   439 								info.GetFieldInfo(EEmailAddress)	
       
   440 								};
       
   441 				TRAP_IGNORE( resultsArray.AppendL( data ) );
       
   442 				}
       
   443 	
       
   444 			//should be done in reuqest complete event for search with erro handling
       
   445 			//also first request complete will be received and then search result event
       
   446 			
       
   447 			for(TInt i=0; i< iSearchObservers.Count(); i++  )
       
   448 				    {
       
   449 				    TRAP_IGNORE( iSearchObservers[i]->HandleSearchResultL(resultsArray) );
       
   450 				   	TRAP_IGNORE( iSearchObservers[i]->HandleSearchFinishedL( KErrNone ) );
       
   451 				    }
       
   452 			
       
   453 			resultsArray.Close();	// close the array
       
   454 			break;
       
   455 			}
       
   456 		case MSearchKeysEvent::KInterfaceId:
       
   457             {
       
   458             const MSearchKeysEvent* searchEvent =
       
   459             TXIMPGetInterface< const MSearchKeysEvent >::From ( aEvent,
       
   460                 MXIMPBase::EPanicIfUnknown );
       
   461             TRAP_IGNORE( ProcessSearchKeysEventL( searchEvent ) );
       
   462             break;
       
   463             }
       
   464         default:
       
   465             {
       
   466             break;
       
   467             }
       
   468         }
       
   469    	TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::HandleSessionContextEventL end"));	
       
   470     }    
       
   471 
       
   472 
       
   473 // ---------------------------------------------------------
       
   474 // CVIMPSTEngineSearchMgrExtention::ProcessSearchKeysEventL
       
   475 // 
       
   476 // ---------------------------------------------------------
       
   477 void CVIMPSTEngineSearchMgrExtention::ProcessSearchKeysEventL(const MSearchKeysEvent* aSearchKeysEvent)
       
   478     {
       
   479     TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::ProcessSearchKeysEventL start"));
       
   480     
       
   481     TInt searchKeysCount = aSearchKeysEvent->InfoCount();
       
   482     
       
   483     RArray<TInt> enumKeyArray;
       
   484     RPointerArray<HBufC> labelKeyArray;
       
   485     
       
   486     CleanupClosePushL( enumKeyArray );
       
   487     CleanupClosePushL( labelKeyArray );
       
   488     
       
   489     HBufC* keyLabelText = NULL;
       
   490     for( TInt i = 0; i < searchKeysCount; i++ )
       
   491         {
       
   492         const MSearchKeyInfo& searchKeyInfo = aSearchKeysEvent->SearchKeyInfo ( i );
       
   493         switch( searchKeyInfo.Type() )
       
   494 	        {
       
   495 	        	case EKey:
       
   496 	        		{
       
   497 	        		//change to proper type once done at ximp side
       
   498 	        		TSearchKey keyValue = searchKeyInfo.Key();
       
   499 	        		TVIMPSTEnums::TVIMPSTSearchKey key = ConverttoTVIMPSTSearchKey(keyValue);
       
   500 	        		enumKeyArray.Append(key);
       
   501 	        		break;		
       
   502 	        		}
       
   503 				case ELabel:
       
   504 	        		{
       
   505 	        		keyLabelText = searchKeyInfo.Label().AllocL();
       
   506 	        		
       
   507 	        		labelKeyArray.Append(keyLabelText);
       
   508 	        		break;		
       
   509 	        		}	        		
       
   510 	        	
       
   511 	        }
       
   512         }
       
   513     
       
   514     for(TInt i=0; i< iSearchObservers.Count(); i++  )
       
   515 	    {
       
   516 	    iSearchObservers[i]->HandleSearchKeysEventL(enumKeyArray, labelKeyArray );	
       
   517 	    }
       
   518 	
       
   519 	CleanupStack::PopAndDestroy(2); //enumKeyArray, labelKeyArray
       
   520     
       
   521     TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::ProcessSearchKeysEventL end"));
       
   522     }
       
   523         
       
   524 // ------------------------------------------------------------------------
       
   525 // CVIMPSTEngineSearchMgrExtention::ConverttoTVIMPSTSearchKey
       
   526 // 
       
   527 // ------------------------------------------------------------------------
       
   528 TVIMPSTEnums::TVIMPSTSearchKey CVIMPSTEngineSearchMgrExtention::ConverttoTVIMPSTSearchKey( TSearchKey aKey)
       
   529     {
       
   530     TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::ConverttoTVIMPSTSearchKey start"));
       
   531     
       
   532      TVIMPSTEnums::TVIMPSTSearchKey retKey = TVIMPSTEnums::EVIMPSTFirstName ;
       
   533      switch( aKey )
       
   534 		{
       
   535 		case EUserFirstName:
       
   536 			{
       
   537 			retKey = TVIMPSTEnums::EVIMPSTFirstName;	        		
       
   538 			break;		
       
   539 			}
       
   540 		case EUserMiddleName:
       
   541 			{
       
   542 			retKey = TVIMPSTEnums::EVIMPSTMiddleName;	        		
       
   543 			break;		
       
   544 			}
       
   545 		case EUserLastName:
       
   546 			{
       
   547 			retKey = TVIMPSTEnums::EVIMPSTLastName;	        		
       
   548 			break;		
       
   549 			}
       
   550 		case EUserFullName:
       
   551 			{
       
   552 			retKey = TVIMPSTEnums::EVIMPSTFullName;	        		
       
   553 			break;		
       
   554 			}
       
   555 		case EUserCountry:
       
   556 			{
       
   557 			retKey = TVIMPSTEnums::EVIMPSTCountry;	        		
       
   558 			break;		
       
   559 			}
       
   560 		case EUserCity:
       
   561 			{
       
   562 			retKey = TVIMPSTEnums::EVIMPSTCity;	        		
       
   563 			break;		
       
   564 			}
       
   565 		case EUserEmailAddress:
       
   566 			{
       
   567 			retKey = TVIMPSTEnums::EVIMPSTEmailAddress;	        		
       
   568 			break;		
       
   569 			}
       
   570 		case EUser:
       
   571 			{
       
   572 			retKey = TVIMPSTEnums::EVIMPSTUser;	        		
       
   573 			break;		
       
   574 			}
       
   575 		case EOrganisation:
       
   576 			{
       
   577 			retKey = TVIMPSTEnums::EVIMPSTOrganisation;	        		
       
   578 			break;		
       
   579 			}
       
   580 			
       
   581 		case  EUserNickName :
       
   582 			{
       
   583 		    retKey = TVIMPSTEnums::EVIMPSTNickName; 		
       
   584 			break;		
       
   585 			}
       
   586 		case EState :
       
   587 			{
       
   588 			retKey = TVIMPSTEnums::EVIMPSTState ; 	 	        		
       
   589 			break;		
       
   590 			}
       
   591 		case  EOrganisationUnit :
       
   592 			{
       
   593 		    retKey = TVIMPSTEnums::EVIMPSTOrganisationUnit;    		
       
   594 			break;		
       
   595 			}
       
   596 		case  EBirthday:
       
   597 			{
       
   598 		    retKey = TVIMPSTEnums::EVIMPSTBirthday;     		
       
   599 			break;		
       
   600 			}
       
   601 			
       
   602 		default:
       
   603 			{
       
   604 			retKey = TVIMPSTEnums::EVIMPSTFirstName;	
       
   605 			}
       
   606 
       
   607 		}
       
   608 	
       
   609 	TRACE( T_LIT("CVIMPSTEngineSearchMgrExtention::ConverttoTVIMPSTSearchKey end"));
       
   610 	return retKey;  
       
   611     }       	
       
   612 //----------------------------------------------------------------------------
       
   613 // CVIMPSTEngineSearchMgrExtention::SetSupported()
       
   614 // -----------------------------------------------------------------------------
       
   615 //
       
   616 void  CVIMPSTEngineSearchMgrExtention::SetSupported(TVIMPSTEnums::FeatureSupport aSupported)
       
   617     { 
       
   618     if ( aSupported == TVIMPSTEnums::ESupportUnKnown)
       
   619         {
       
   620         // at the logout time this flag  has to be set to EFalse
       
   621         iAlreadySubscibed = EFalse;
       
   622         }
       
   623     iSearchSupported = aSupported;
       
   624     }
       
   625 
       
   626 // end of file