uiservicetab/vimpstengine/src/cvimpstenginepresencesubservice.cpp
branchRCL_3
changeset 14 9fdee5e1da30
parent 0 5e5d6b214f4f
equal deleted inserted replaced
13:796276a1bdcc 14:9fdee5e1da30
    71 #include   <ximpfeatureinfo.h>
    71 #include   <ximpfeatureinfo.h>
    72 #include <avabilitytext.h>
    72 #include <avabilitytext.h>
    73 
    73 
    74 //Presence Observer
    74 //Presence Observer
    75 #include "mvimpstenginepresencesubserviceeventobserver.h"
    75 #include "mvimpstenginepresencesubserviceeventobserver.h"
    76 #include "vimpstdebugtrace.h"
    76 #include "uiservicetabtracer.h"
    77 #include "vimpstcustomcleanupapi.h" //For customized cleanup function
    77 #include "vimpstcustomcleanupapi.h" //For customized cleanup function
    78 #include "mvimpstengineserviceconnectioneventobserver.h"
    78 #include "mvimpstengineserviceconnectioneventobserver.h"
    79 
    79 
    80 // CONTANTS
    80 // CONTANTS
    81 const TInt KUriMaxLength = 255; 
    81 const TInt KUriMaxLength = 255; 
   111     iChangeStatusSupported ( ETrue ),
   111     iChangeStatusSupported ( ETrue ),
   112     iChangeStatusMsgSupported( ETrue ),
   112     iChangeStatusMsgSupported( ETrue ),
   113     iAvatarSupported( EFalse ),
   113     iAvatarSupported( EFalse ),
   114     iIsClearingAvatar(EFalse)
   114     iIsClearingAvatar(EFalse)
   115         {
   115         {
   116         TRACE( T_LIT("CVIMPSTEnginePrecenseSubService::CVIMPSTEnginePrecenseSubService start")); 
   116 	TRACER_AUTO;
   117         TRACE( T_LIT("CVIMPSTEnginePrecenseSubService::CVIMPSTEnginePrecenseSubService end"));
       
   118         }
   117         }
   119 
   118 
   120 // ---------------------------------------------------------------------------
   119 // ---------------------------------------------------------------------------
   121 // CVIMPSTEnginePresenceSubService::ConstructL()
   120 // CVIMPSTEnginePresenceSubService::ConstructL()
   122 // ---------------------------------------------------------------------------
   121 // ---------------------------------------------------------------------------
   123 //
   122 //
   124 void CVIMPSTEnginePresenceSubService::ConstructL()
   123 void CVIMPSTEnginePresenceSubService::ConstructL()
   125     {
   124     {
   126     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::ConstructL start")); 
   125 	TRACER_AUTO;
   127 
   126 
   128     iCchHandler.RegisterCchObserverL(this,ECCHPresenceSub);
   127     iCchHandler.RegisterCchObserverL(this,ECCHPresenceSub);
   129 
   128 
   130     TCCHSubserviceState serviceState = ECCHUninitialized;    
   129     TCCHSubserviceState serviceState = ECCHUninitialized;    
   131     TInt error = iCchHandler.GetServiceState( 
   130     TInt error = iCchHandler.GetServiceState( 
   143     iBlockListFetchReqPending = EFalse; //req of fetching blocked list has been completed.
   142     iBlockListFetchReqPending = EFalse; //req of fetching blocked list has been completed.
   144     
   143     
   145 	iLogoutRequest = EFalse;
   144 	iLogoutRequest = EFalse;
   146 	iSubscribeToAuthList = EFalse;
   145 	iSubscribeToAuthList = EFalse;
   147 	iAutoAccept = EFalse;
   146 	iAutoAccept = EFalse;
   148     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::ConstructL end")); 
       
   149 
   147 
   150     }
   148     }
   151 
   149 
   152 // ---------------------------------------------------------------------------
   150 // ---------------------------------------------------------------------------
   153 // CVIMPSTEnginePresenceSubService::NewL()
   151 // CVIMPSTEnginePresenceSubService::NewL()
   158         CVIMPSTEngineCchHandler& aCchHandler,
   156         CVIMPSTEngineCchHandler& aCchHandler,
   159         CVIMPSTEngineServiceTableFetcher& aTableFetcher,
   157         CVIMPSTEngineServiceTableFetcher& aTableFetcher,
   160         CVIMPSTEngineSessionCntxtObserver& aXimpEventObserver,
   158         CVIMPSTEngineSessionCntxtObserver& aXimpEventObserver,
   161         MVIMPSTEngineServiceConnectionEventObserver& aObserver )
   159         MVIMPSTEngineServiceConnectionEventObserver& aObserver )
   162     {
   160     {
   163     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::NewL start")); 
   161 	TRACER_AUTO;
   164     CVIMPSTEnginePresenceSubService* self = NewLC( aServiceId,aCchHandler, aTableFetcher, 
   162     CVIMPSTEnginePresenceSubService* self = NewLC( aServiceId,aCchHandler, aTableFetcher, 
   165             aXimpEventObserver,aObserver );
   163             aXimpEventObserver,aObserver );
   166     CleanupStack::Pop(self);
   164     CleanupStack::Pop(self);
   167     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::NewL end"));
       
   168     return self;
   165     return self;
   169     }
   166     }
   170 
   167 
   171 // ---------------------------------------------------------------------------
   168 // ---------------------------------------------------------------------------
   172 // CVIMPSTEnginePresenceSubService::NewLC()
   169 // CVIMPSTEnginePresenceSubService::NewLC()
   177         CVIMPSTEngineCchHandler& aCchHandler,
   174         CVIMPSTEngineCchHandler& aCchHandler,
   178         CVIMPSTEngineServiceTableFetcher& aTableFetcher,
   175         CVIMPSTEngineServiceTableFetcher& aTableFetcher,
   179         CVIMPSTEngineSessionCntxtObserver& aXimpEventObserver,
   176         CVIMPSTEngineSessionCntxtObserver& aXimpEventObserver,
   180         MVIMPSTEngineServiceConnectionEventObserver& aObserver )
   177         MVIMPSTEngineServiceConnectionEventObserver& aObserver )
   181     {
   178     {
   182     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::NewLC start")); 
   179 	TRACER_AUTO;
   183     CVIMPSTEnginePresenceSubService* self =
   180     CVIMPSTEnginePresenceSubService* self =
   184     new (ELeave) CVIMPSTEnginePresenceSubService( aServiceId,aCchHandler, aTableFetcher,  aXimpEventObserver,aObserver);
   181     new (ELeave) CVIMPSTEnginePresenceSubService( aServiceId,aCchHandler, aTableFetcher,  aXimpEventObserver,aObserver);
   185     CleanupStack::PushL(self);
   182     CleanupStack::PushL(self);
   186     self->ConstructL();
   183     self->ConstructL();
   187     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::NewLC end")); 
       
   188     return self;
   184     return self;
   189     }
   185     }
   190 
   186 
   191 // ---------------------------------------------------------------------------
   187 // ---------------------------------------------------------------------------
   192 // CVIMPSTEnginePresenceSubService::
   188 // CVIMPSTEnginePresenceSubService::
   193 //      ~CVIMPSTEnginePresenceSubService()
   189 //      ~CVIMPSTEnginePresenceSubService()
   194 // ---------------------------------------------------------------------------
   190 // ---------------------------------------------------------------------------
   195 //
   191 //
   196 CVIMPSTEnginePresenceSubService::~CVIMPSTEnginePresenceSubService()
   192 CVIMPSTEnginePresenceSubService::~CVIMPSTEnginePresenceSubService()
   197     {
   193     {
   198     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::NewLC start")); 
   194 	TRACER_AUTO;
   199 	
   195 	
   200 	iCchHandler.UnRegisterCchObserver(ECCHPresenceSub);
   196 	iCchHandler.UnRegisterCchObserver(ECCHPresenceSub);
   201     
   197     
   202     delete iServiceName;
   198     delete iServiceName;
   203     delete iPresenceCacheReader ; 
   199     delete iPresenceCacheReader ; 
   204     
   200     
   205     delete iBlockedListMgr;
   201     delete iBlockedListMgr;
   206     iBlockedListMgr = NULL;
   202     iBlockedListMgr = NULL;
   207        
   203        
   208     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::NewLC end")); 
       
   209     }
   204     }
   210 
   205 
   211 // ---------------------------------------------------------------------------
   206 // ---------------------------------------------------------------------------
   212 // CVIMPSTEnginePresenceSubService::
   207 // CVIMPSTEnginePresenceSubService::
   213 //      ServiceState()
   208 //      ServiceState()
   214 // ---------------------------------------------------------------------------
   209 // ---------------------------------------------------------------------------
   215 //
   210 //
   216 
   211 
   217 TVIMPSTEnums::TVIMPSTRegistrationState CVIMPSTEnginePresenceSubService::SubServiceState() const
   212 TVIMPSTEnums::TVIMPSTRegistrationState CVIMPSTEnginePresenceSubService::SubServiceState() const
   218 	{
   213 	{
   219 	TRACE( T_LIT("CVIMPSTEnginePresenceSubService::ServiceState start")); 
   214 	TRACER_AUTO;
   220 	return iServiceState;
   215 	return iServiceState;
   221 	}
   216 	}
   222 
   217 
   223 // ---------------------------------------------------------------------------
   218 // ---------------------------------------------------------------------------
   224 // CVIMPSTEnginePresenceSubService::
   219 // CVIMPSTEnginePresenceSubService::
   225 //      Type()
   220 //      Type()
   226 // ---------------------------------------------------------------------------
   221 // ---------------------------------------------------------------------------
   227 //
   222 //
   228 TVIMPSTEnums::SubServiceType CVIMPSTEnginePresenceSubService::Type() const
   223 TVIMPSTEnums::SubServiceType CVIMPSTEnginePresenceSubService::Type() const
   229 	{
   224 	{
   230 	TRACE( T_LIT("CVIMPSTEnginePresenceSubService::Type") ); 
   225 	TRACER_AUTO;
   231 	TRACE( T_LIT("CVIMPSTEnginePresenceSubService: [0x%x]"), this );		    	
   226 	TRACE( "CVIMPSTEnginePresenceSubService: [0x%x]", this );
   232 	return TVIMPSTEnums::EPresence;
   227 	return TVIMPSTEnums::EPresence;
   233 	}
   228 	}
   234 
   229 
   235 // ---------------------------------------------------------------------------
   230 // ---------------------------------------------------------------------------
   236 // CVIMPSTEnginePresenceSubService::
   231 // CVIMPSTEnginePresenceSubService::
   238 // ---------------------------------------------------------------------------
   233 // ---------------------------------------------------------------------------
   239 //
   234 //
   240 
   235 
   241 TBool CVIMPSTEnginePresenceSubService::Enabled()
   236 TBool CVIMPSTEnginePresenceSubService::Enabled()
   242     {
   237     {
   243     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::Enabled start")); 
   238 	TRACER_AUTO;
   244     TBool ret = EFalse;
   239     TBool ret = EFalse;
   245     if( TVIMPSTEnums::ESVCERegistered == iServiceState)
   240     if( TVIMPSTEnums::ESVCERegistered == iServiceState)
   246         {
   241         {
   247         ret = ETrue;
   242         ret = ETrue;
   248         }
   243         }
   249     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::Enabled end")); 
       
   250     return ret;    
   244     return ret;    
   251     }
   245     }
   252 
   246 
   253 // ---------------------------------------------------------------------------
   247 // ---------------------------------------------------------------------------
   254 // CVIMPSTEnginePresenceSubService::RetrieveSubscribedListL
   248 // CVIMPSTEnginePresenceSubService::RetrieveSubscribedListL
   255 // ---------------------------------------------------------------------------
   249 // ---------------------------------------------------------------------------
   256 //
   250 //
   257 void CVIMPSTEnginePresenceSubService::RetrieveSubscribedListL()
   251 void CVIMPSTEnginePresenceSubService::RetrieveSubscribedListL()
   258     {
   252     {
   259     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::RetrieveSubscribedListL start")); 
   253 	TRACER_AUTO;
   260 
   254 
   261     //Create group id
   255     //Create group id
   262     TBuf<KUriMaxLength> buffer( KListNameAllBuddy );
   256     TBuf<KUriMaxLength> buffer( KListNameAllBuddy );
   263     MXIMPIdentity* groupList = iXimpEventObserver.XimpPresenceContextL().ObjectFactory().NewIdentityLC();
   257     MXIMPIdentity* groupList = iXimpEventObserver.XimpPresenceContextL().ObjectFactory().NewIdentityLC();
   264      __ASSERT_ALWAYS( groupList , User::Leave( KErrNoMemory ) );		
   258      __ASSERT_ALWAYS( groupList , User::Leave( KErrNoMemory ) );		
   271             *groupList );
   265             *groupList );
   272     CVIMPSTEngineRequestMapper* requestMapper =iXimpEventObserver.GetRequestMapper();
   266     CVIMPSTEngineRequestMapper* requestMapper =iXimpEventObserver.GetRequestMapper();
   273     requestMapper->CreateRequestL(operationId,EFalse,EVIMPSTXimpOperationGetSubscribedList);
   267     requestMapper->CreateRequestL(operationId,EFalse,EVIMPSTXimpOperationGetSubscribedList);
   274     CleanupStack::PopAndDestroy(); // groupList
   268     CleanupStack::PopAndDestroy(); // groupList
   275     // list retrieving ok. Waiting for list.;
   269     // list retrieving ok. Waiting for list.;
   276     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::RetrieveSubscribedListL end")); 
       
   277     }
   270     }
   278 
   271 
   279 // ---------------------------------------------------------------------------
   272 // ---------------------------------------------------------------------------
   280 // CVIMPSTEnginePresenceSubService::SubscribePresenceOfSingleContactL
   273 // CVIMPSTEnginePresenceSubService::SubscribePresenceOfSingleContactL
   281 // ---------------------------------------------------------------------------
   274 // ---------------------------------------------------------------------------
   282 //
   275 //
   283 void CVIMPSTEnginePresenceSubService::SubscribePresenceOfSingleContactL( const TDesC& aUriOfTheContact)
   276 void CVIMPSTEnginePresenceSubService::SubscribePresenceOfSingleContactL( const TDesC& aUriOfTheContact)
   284     {
   277     {
   285     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::SubscribePrecenseOfSingleContactL start"));
   278 	TRACER_AUTO;
   286      __ASSERT_ALWAYS( aUriOfTheContact.Length(), User::Leave( KErrArgument ) );		
   279      __ASSERT_ALWAYS( aUriOfTheContact.Length(), User::Leave( KErrArgument ) );		
   287      //if anything is there with colon eg sip:user@presence1. strip the part before :
   280      //if anything is there with colon eg sip:user@presence1. strip the part before :
   288     TInt len = aUriOfTheContact.Find(_L(":"));
   281     TInt len = aUriOfTheContact.Find(_L(":"));
   289     TPtrC buddyId = aUriOfTheContact.Right( aUriOfTheContact.Length() - len - KColon().Length());
   282     TPtrC buddyId = aUriOfTheContact.Right( aUriOfTheContact.Length() - len - KColon().Length());
   290     HBufC* name = HBufC::NewLC( KPropertyMaxLength );
   283     HBufC* name = HBufC::NewLC( KPropertyMaxLength );
   294     // append the service name followed by user id ,seperated by colon
   287     // append the service name followed by user id ,seperated by colon
   295     namePtr.Append(*iServiceName);
   288     namePtr.Append(*iServiceName);
   296     namePtr.Append(KColon);
   289     namePtr.Append(KColon);
   297     namePtr.Append(buddyId);
   290     namePtr.Append(buddyId);
   298     
   291     
   299     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::SubscribeToPresenceCacheL: %S"), &namePtr );
   292     TRACE("SubscribeToPresenceCacheL: %S", &namePtr );
   300     iPresenceCacheReader->SubscribePresenceBuddyChangeL(*name);
   293     iPresenceCacheReader->SubscribePresenceBuddyChangeL(*name);
   301     CleanupStack::PopAndDestroy(name); //  name    
   294     CleanupStack::PopAndDestroy(name); //  name    
   302     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::SubscribePrecenseOfSingleContactL end"));  
       
   303     }
   295     }
   304 
   296 
   305 // ---------------------------------------------------------------------------
   297 // ---------------------------------------------------------------------------
   306 // CVIMPSTEnginePresenceSubService::
   298 // CVIMPSTEnginePresenceSubService::
   307 //      UnsubscribePrecenseOfSingleContactL
   299 //      UnsubscribePrecenseOfSingleContactL
   308 // ---------------------------------------------------------------------------
   300 // ---------------------------------------------------------------------------
   309 //
   301 //
   310 void CVIMPSTEnginePresenceSubService::UnSubscribePresenceOfSingleContactL(
   302 void CVIMPSTEnginePresenceSubService::UnSubscribePresenceOfSingleContactL(
   311         const TDesC& aUriOfTheContact )
   303         const TDesC& aUriOfTheContact )
   312     {
   304     {
   313     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::UnsubscribePrecenseOfSingleContactL start"));   
   305 	TRACER_AUTO;
   314     HBufC* name = HBufC::NewLC( KPropertyMaxLength );
   306     HBufC* name = HBufC::NewLC( KPropertyMaxLength );
   315     TPtr namePtr( name->Des() );
   307     TPtr namePtr( name->Des() );
   316     namePtr.Zero();
   308     namePtr.Zero();
   317     // append the service name followed by user id ,seperated by colon
   309     // append the service name followed by user id ,seperated by colon
   318     namePtr.Append(*iServiceName);
   310     namePtr.Append(*iServiceName);
   319     namePtr.Append(KColon);
   311     namePtr.Append(KColon);
   320     namePtr.Append(aUriOfTheContact);
   312     namePtr.Append(aUriOfTheContact);
   321     
   313     
   322     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::UnSubscribeToPresenceCacheL: %S"), &namePtr);
   314     TRACE( "UnSubscribeToPresenceCacheL: %S", &namePtr);
   323     iPresenceCacheReader->UnSubscribePresenceBuddyChangeL(*name);
   315     iPresenceCacheReader->UnSubscribePresenceBuddyChangeL(*name);
   324     CleanupStack::PopAndDestroy(name); //  name                  
   316     CleanupStack::PopAndDestroy(name); //  name                  
   325     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::UnsubscribePrecenseOfSingleContactL end")) ;   
       
   326     }
   317     }
   327 
   318 
   328 // ---------------------------------------------------------------------------
   319 // ---------------------------------------------------------------------------
   329 // CVIMPSTEnginePresenceSubService::
   320 // CVIMPSTEnginePresenceSubService::
   330 //      DoHandlePresentityGroupContentEventL
   321 //      DoHandlePresentityGroupContentEventL
   333 void CVIMPSTEnginePresenceSubService::
   324 void CVIMPSTEnginePresenceSubService::
   334 DoHandlePresentityGroupContentEventL(
   325 DoHandlePresentityGroupContentEventL(
   335         const MXIMPContext& /*aContext*/,
   326         const MXIMPContext& /*aContext*/,
   336         const MXIMPBase& aEvent )
   327         const MXIMPBase& aEvent )
   337     {
   328     {
   338     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresentityGroupContentEventL start"));
   329 	TRACER_AUTO;
   339 	  	      
   330 	  	      
   340     const MPresentityGroupContentEvent& event =
   331     const MPresentityGroupContentEvent& event =
   341     	*TXIMPGetInterface< const MPresentityGroupContentEvent >::From( 
   332     	*TXIMPGetInterface< const MPresentityGroupContentEvent >::From( 
   342             aEvent,
   333             aEvent,
   343             MXIMPBase::EPanicIfUnknown );
   334             MXIMPBase::EPanicIfUnknown );
   344     //this needs to be checked if server contacts is supported only then update to 
   335     //this needs to be checked if server contacts is supported only then update to 
   345     //store else don't.
   336     //store else don't.
   346 	TInt supportedFeatures = iXimpEventObserver.GetSupportedFeatures();
   337 	TInt supportedFeatures = iXimpEventObserver.GetSupportedFeatures();
   347   	if(EVIMPSTFeatureFetch & supportedFeatures)
   338   	if(EVIMPSTFeatureFetch & supportedFeatures)
   348 		{   
   339 		{   
   349 	    TRACE( T_LIT(" -> storing into respective service store" ));
   340   	TRACE(" -> storing into respective service store" );
   350 	    StoreToVirtualStoreL( event );
   341 	    StoreToVirtualStoreL( event );
   351 		}
   342 		}
   352 	//this is to ensure the presence for the local sotre contacts is not lost.
   343 	//this is to ensure the presence for the local sotre contacts is not lost.
   353 	TRACE( T_LIT(" -> new member count: %d" ), event.NewMembersCount() );    
   344   	TRACE( "new member count: %d" , event.NewMembersCount() ); 
   354     TRACE( T_LIT(" -> current member count: %d" ), event.CurrentMembersCount() );    
   345     TRACE( " current member count: %d" , event.CurrentMembersCount() );  
   355     TRACE( T_LIT(" -> disappeared member count: %d" ), event.DisappearedMembersCount() );    
   346     TRACE( "disappeared member count: %d" , event.DisappearedMembersCount() );   
   356     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresentityGroupContentEventL end"));
       
   357     }
   347     }
   358 
   348 
   359 // ---------------------------------------------------------------------------
   349 // ---------------------------------------------------------------------------
   360 // CVIMPSTEnginePresenceSubService::
   350 // CVIMPSTEnginePresenceSubService::
   361 //      DoHandlePresenceGrantRequestListEventL
   351 //      DoHandlePresenceGrantRequestListEventL
   364 void CVIMPSTEnginePresenceSubService::
   354 void CVIMPSTEnginePresenceSubService::
   365 DoHandlePresenceGrantRequestListEventL(
   355 DoHandlePresenceGrantRequestListEventL(
   366         const MXIMPContext& /*aContext*/,
   356         const MXIMPContext& /*aContext*/,
   367         const MXIMPBase& aEvent )
   357         const MXIMPBase& aEvent )
   368     {
   358     {
   369     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceGrantRequestListEventL start"));
   359 	TRACER_AUTO;
   370     TVIMPSTEnums::TVIMPSTPresenceRequestStatus autoAccept = iSettingsTableFetcher.PresenceRequestStatusL(iServiceId);
   360     TVIMPSTEnums::TVIMPSTPresenceRequestStatus autoAccept = iSettingsTableFetcher.PresenceRequestStatusL(iServiceId);
   371     if(autoAccept == TVIMPSTEnums::ESVCEPresenceRequestStatusAutoAccept)
   361     if(autoAccept == TVIMPSTEnums::ESVCEPresenceRequestStatusAutoAccept)
   372         {
   362         {
   373         iAutoAccept = ETrue;
   363         iAutoAccept = ETrue;
   374         }
   364         }
   379     
   369     
   380      const MPresenceGrantRequestListEvent& event = 
   370      const MPresenceGrantRequestListEvent& event = 
   381      							*TXIMPGetInterface<const MPresenceGrantRequestListEvent >::From( 
   371      							*TXIMPGetInterface<const MPresenceGrantRequestListEvent >::From( 
   382 								aEvent, MXIMPBase::EPanicIfUnknown );
   372 								aEvent, MXIMPBase::EPanicIfUnknown );
   383 
   373 
   384     TRACE( T_LIT(" -> new watcher count: %d" ), event.NewRequestsCount() );    
   374      TRACE("new watcher count: %d" , event.NewRequestsCount() );   
   385     TRACE( T_LIT(" -> current watcher count: %d" ), event.CurrentRequestsCount() );    
   375      TRACE("current watcher count: %d" , event.CurrentRequestsCount() ); 
   386     HBufC* identbuf(NULL);
   376     HBufC* identbuf(NULL);
   387     HBufC* displayName(NULL);
   377     HBufC* displayName(NULL);
   388     TInt newcount     = event.NewRequestsCount();
   378     TInt newcount     = event.NewRequestsCount();
   389     TInt currentcount = event.CurrentRequestsCount();
   379     TInt currentcount = event.CurrentRequestsCount();
   390     if(newcount)
   380     if(newcount)
   391         {
   381         {
   392         TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceGrantRequestListEventL newcount =%d" ), newcount );    
   382     TRACE( " newcount =%d" , newcount );    
   393         TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceGrantRequestListEventL iServiceState =%d" ), iServiceState );    
   383     TRACE( "iServiceState =%d" , iServiceState );    
   394 
   384 
   395         for(TInt i=0; i<newcount; i++)
   385         for(TInt i=0; i<newcount; i++)
   396             {
   386             {
   397             const MPresenceGrantRequestInfo& reqInfo = event.NewRequest ( i );// its always a new request
   387             const MPresenceGrantRequestInfo& reqInfo = event.NewRequest ( i );// its always a new request
   398             identbuf = reqInfo.RequestorId().Identity().AllocLC();
   388             identbuf = reqInfo.RequestorId().Identity().AllocLC();
   399             displayName = reqInfo.RequestorDisplayName().AllocLC();
   389             displayName = reqInfo.RequestorDisplayName().AllocLC();
   400             TPtr identbufPtr = identbuf->Des();
   390             TPtr identbufPtr = identbuf->Des();
   401             TRACE( T_LIT(" -> identity: %S" ), &identbufPtr );   
   391             TRACE( "identity: %S" , &identbufPtr );   
   402             if(identbuf->Length())
   392             if(identbuf->Length())
   403                 {
   393                 {
   404                 TRACE( T_LIT(" -> pass to command process" ));   
   394             TRACE( " pass to command process" );   
   405                 if( iAutoAccept &&
   395                 if( iAutoAccept &&
   406                         TVIMPSTEnums::ESVCERegistered == iServiceState)
   396                         TVIMPSTEnums::ESVCERegistered == iServiceState)
   407                     {
   397                     {
   408                     TInt error = SendPresenceGrantPresentityL( identbufPtr, ETrue );                    
   398                     TInt error = SendPresenceGrantPresentityL( identbufPtr, ETrue );                    
   409                     }
   399                     }
   410                  else if( iSubServiceObserver )
   400                  else if( iSubServiceObserver )
   411                     {
   401                     {
   412                     TRACE( T_LIT(" -> informed observer." )); 
   402                  TRACE( " informed observer." ); 
   413                     iSubServiceObserver->HandleAddRequestEventL( TVIMPSTEnums::EAddItem , *identbuf, *displayName);
   403                     iSubServiceObserver->HandleAddRequestEventL( TVIMPSTEnums::EAddItem , *identbuf, *displayName);
   414                     }                    
   404                     }                    
   415                 TRACE( T_LIT(" -> pass to command process" )); 
   405                 TRACE( " pass to command process" );
   416                 }
   406                 }
   417             CleanupStack::PopAndDestroy( displayName );
   407             CleanupStack::PopAndDestroy( displayName );
   418             CleanupStack::PopAndDestroy( identbuf );
   408             CleanupStack::PopAndDestroy( identbuf );
   419             }
   409             }
   420         }
   410         }
   422         {
   412         {
   423         const MPresenceGrantRequestInfo& reqInfo = event.CurrentRequest(0 );// its always a new request
   413         const MPresenceGrantRequestInfo& reqInfo = event.CurrentRequest(0 );// its always a new request
   424         identbuf = reqInfo.RequestorId().Identity().AllocLC();
   414         identbuf = reqInfo.RequestorId().Identity().AllocLC();
   425         displayName  = reqInfo.RequestorDisplayName().AllocLC();
   415         displayName  = reqInfo.RequestorDisplayName().AllocLC();
   426         TPtr identbufPtr = identbuf->Des();
   416         TPtr identbufPtr = identbuf->Des();
   427         TRACE( T_LIT(" -> identity: %S" ), &identbufPtr );   
   417         TRACE( "identity: %S" , &identbufPtr );  
   428         if(identbuf->Length())
   418         if(identbuf->Length())
   429             {
   419             {
   430             TRACE( T_LIT(" -> pass to command process" ));   
   420         TRACE( " pass to command process" );
   431             if( iAutoAccept)
   421             if( iAutoAccept)
   432                 {
   422                 {
   433                 TInt error = SendPresenceGrantPresentityL( identbufPtr, ETrue );                    
   423                 TInt error = SendPresenceGrantPresentityL( identbufPtr, ETrue );                    
   434                 }
   424                 }
   435              else if( iSubServiceObserver )
   425              else if( iSubServiceObserver )
   436                 {
   426                 {
   437                 TRACE( T_LIT(" -> informed observer." )); 
   427              TRACE( " informed observer."); 
   438                 iSubServiceObserver->HandleAddRequestEventL(TVIMPSTEnums::EAddItem ,*identbuf, *displayName);
   428                 iSubServiceObserver->HandleAddRequestEventL(TVIMPSTEnums::EAddItem ,*identbuf, *displayName);
   439                 }      
   429                 }      
   440             TRACE( T_LIT(" -> pass to command process" )); 
   430             TRACE( "pass to command process" ); 
   441             }
   431             }
   442         CleanupStack::PopAndDestroy( displayName );
   432         CleanupStack::PopAndDestroy( displayName );
   443         CleanupStack::PopAndDestroy ( identbuf );
   433         CleanupStack::PopAndDestroy ( identbuf );
   444         }    
   434         }    
   445     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceGrantRequestListEventL end"));
       
   446 
   435 
   447     }
   436     }
   448 
   437 
   449 // ---------------------------------------------------------------------------
   438 // ---------------------------------------------------------------------------
   450 // CVIMPSTEnginePresenceSubService::ResolveServiceStateL
   439 // CVIMPSTEnginePresenceSubService::ResolveServiceStateL
   453 TVIMPSTEnums::TVIMPSTRegistrationState CVIMPSTEnginePresenceSubService::ResolveServiceStateL(
   442 TVIMPSTEnums::TVIMPSTRegistrationState CVIMPSTEnginePresenceSubService::ResolveServiceStateL(
   454         TCCHSubserviceState aState, 
   443         TCCHSubserviceState aState, 
   455         TInt aServiceError )
   444         TInt aServiceError )
   456     {
   445     {
   457 
   446 
   458     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::ResolveServiceStateL start"));    
   447 	TRACER_AUTO;
   459 
   448 
   460     TVIMPSTEnums::TVIMPSTRegistrationState state = TVIMPSTEnums::ESVCENotRegistered;       
   449     TVIMPSTEnums::TVIMPSTRegistrationState state = TVIMPSTEnums::ESVCENotRegistered;       
   461 
   450 
   462     TRACE( T_LIT("ResolveServiceStateL() iServiceId: %d, ServiceState: %d"), 
   451     
   463             iServiceId, aState );       
   452     TRACE( " iServiceId: %d, ServiceState: %d",  iServiceId, aState ); 
   464 
   453 
   465     TBool handleServiceStates = ETrue;
   454     TBool handleServiceStates = ETrue;
   466     if ( aServiceError && ECCHDisabled != aState )
   455     if ( aServiceError && ECCHDisabled != aState )
   467         {    
   456         {    
   468         //Only if the Service supports ALR, the state can goto WaitingForNetwork
   457         //Only if the Service supports ALR, the state can goto WaitingForNetwork
   469         //Still API from CCH is required to know whether ALR is supported or not
   458         //Still API from CCH is required to know whether ALR is supported or not
   470         //Not sure whether the below is right - have mailed to Markus for MoreInfo on this state
   459         //Not sure whether the below is right - have mailed to Markus for MoreInfo on this state
   471         if ( (KCCHErrorInvalidSettings != aServiceError) && (ECCHConnecting == aState) )        
   460         if ( (KCCHErrorInvalidSettings != aServiceError) && (ECCHConnecting == aState) )        
   472             {   
   461             {   
   473             TRACE( T_LIT("ResolveServiceStateL() ESVCEWaitingForNetwork") );
   462             TRACE( " ESVCEWaitingForNetwork");
   474             handleServiceStates = EFalse;  
   463             handleServiceStates = EFalse;  
   475             //state = TVIMPSTEnums::ESVCEWaitingForNetwork;
   464             //state = TVIMPSTEnums::ESVCEWaitingForNetwork;
   476             state = TVIMPSTEnums::ESVCENotRegistered; 
   465             state = TVIMPSTEnums::ESVCENotRegistered; 
   477             }
   466             }
   478         }
   467         }
   481         {        
   470         {        
   482         switch ( aState )
   471         switch ( aState )
   483             {
   472             {
   484             case ECCHEnabled:
   473             case ECCHEnabled:
   485                 {
   474                 {
   486                 TRACE( T_LIT("ResolveServiceStateL() ESVCERegistered") );
   475                 TRACE( "ESVCERegistered" );
   487                 state = TVIMPSTEnums::ESVCEUpdatingContacts;   
   476                 state = TVIMPSTEnums::ESVCEUpdatingContacts;   
   488                 break;
   477                 break;
   489                 }
   478                 }
   490             case ECCHDisconnecting:      
   479             case ECCHDisconnecting:      
   491                 {
   480                 {
   492                 TRACE( T_LIT("ResolveServiceStateL() ESVCERegistered") );                
   481                 TRACE( " ESVCERegistered" );   
   493                 state = TVIMPSTEnums::ESVCENetworkDisConnecting;
   482                 state = TVIMPSTEnums::ESVCENetworkDisConnecting;
   494                 }
   483                 }
   495                 break;
   484                 break;
   496 
   485 
   497             case ECCHUninitialized:
   486             case ECCHUninitialized:
   498             case ECCHDisabled:  
   487             case ECCHDisabled:  
   499                 {
   488                 {
   500                 TRACE( T_LIT("ResolveServiceStateL() ESVCENotRegistered") );
   489                 TRACE( "ESVCENotRegistered");
   501                 state = TVIMPSTEnums::ESVCENotRegistered;                
   490                 state = TVIMPSTEnums::ESVCENotRegistered;                
   502                 }
   491                 }
   503                 break;
   492                 break;
   504 
   493 
   505             case ECCHConnecting:               
   494             case ECCHConnecting:               
   506                 {
   495                 {
   507                 TRACE( T_LIT("ResolveServiceStateL() ESVCENoNetworkConnecting") );                
   496                 TRACE( " ESVCENoNetworkConnecting");  
   508                 state = TVIMPSTEnums::ESVCENetworkConnecting;
   497                 state = TVIMPSTEnums::ESVCENetworkConnecting;
   509                 }
   498                 }
   510                 break;
   499                 break;
   511 
   500 
   512             default:
   501             default:
   513                 break;
   502                 break;
   514             }
   503             }
   515         }        
   504         }        
   516 
   505 
   517     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::ResolveServiceStateL end"));
       
   518 
   506 
   519     return state;  
   507     return state;  
   520 
   508 
   521     }
   509     }
   522 
   510 
   529         TUint /*aServiceId*/, 
   517         TUint /*aServiceId*/, 
   530         TCCHSubserviceState aState, 
   518         TCCHSubserviceState aState, 
   531         TInt aServiceError )
   519         TInt aServiceError )
   532     {
   520     {
   533 
   521 
   534     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::CchEventOccuredL start"));
   522 	TRACER_AUTO;
   535     TRACE( T_LIT("CchEventOccuredL() TCCHSubserviceState : %d, ServiceErr: %d"), 
   523 	
   536             aState, aServiceError );
   524     TRACE("TCCHSubserviceState : %d, ServiceErr: %d", aState, aServiceError );
   537 
   525 
   538     if ( aServiceError && ECCHDisabled != aState )
   526     if ( aServiceError && ECCHDisabled != aState )
   539         {
   527         {
   540         //we might even end up in waiting for connection state for all
   528         //we might even end up in waiting for connection state for all
   541         //those service which are ALR enabled
   529         //those service which are ALR enabled
   564 			{
   552 			{
   565 			iServiceState = ResolveServiceStateL( aState, aServiceError );    
   553 			iServiceState = ResolveServiceStateL( aState, aServiceError );    
   566 		    iObserver.HandleServceConnectionEventL();			}
   554 		    iObserver.HandleServceConnectionEventL();			}
   567         }   
   555         }   
   568 
   556 
   569     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::CchEventOccuredL end"));
       
   570 
   557 
   571     }
   558     }
   572 
   559 
   573 
   560 
   574 // ---------------------------------------------------------------------------
   561 // ---------------------------------------------------------------------------
   577 // 
   564 // 
   578 void CVIMPSTEnginePresenceSubService::DoHandleCchErrorL( 
   565 void CVIMPSTEnginePresenceSubService::DoHandleCchErrorL( 
   579         TInt aServiceError )
   566         TInt aServiceError )
   580     {
   567     {
   581 
   568 
   582     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandleCchErrorL start"));
   569 	TRACER_AUTO;
   583     TRACE( T_LIT("DoHandleCchErrorL() ServiceErr: %d"), 
   570 	   TRACE( "ServiceErr: %d",  aServiceError );
   584             aServiceError );
       
   585 
   571 
   586     if ( aServiceError )
   572     if ( aServiceError )
   587         {
   573         {
   588         //unsubscribe can only be done, when bind is already done
   574         //unsubscribe can only be done, when bind is already done
   589         if(TVIMPSTEnums::EVIMPSTBindDone ==iXimpEventObserver.ContextBindStatus())
   575         if(TVIMPSTEnums::EVIMPSTBindDone ==iXimpEventObserver.ContextBindStatus())
   590             {
   576             {
   591             TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandleCchErrorL unscribe and unbind"));
   577             TRACE( "unscribe and unbind");
   592             TRAP_IGNORE( UnsubscribeListsL() ); 
   578             TRAP_IGNORE( UnsubscribeListsL() ); 
   593             iXimpEventObserver.ServerUnBindL( ETrue );
   579             iXimpEventObserver.ServerUnBindL( ETrue );
   594             }
   580             }
   595         }
   581         }
   596     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandleCchErrorL end"));
   582 
       
   583 
   597     }
   584     }
   598 
   585 
   599 // ---------------------------------------------------------
   586 // ---------------------------------------------------------
   600 // CVIMPSTEnginePresenceSubService::PublishOwnPresenceL
   587 // CVIMPSTEnginePresenceSubService::PublishOwnPresenceL
   601 // 
   588 // 
   604 														  const TDesC& aValue,
   591 														  const TDesC& aValue,
   605 						         						  const TDesC& aFilename /*= KNullDesC*/, 
   592 						         						  const TDesC& aFilename /*= KNullDesC*/, 
   606 						         						  const TDesC8& aMimetype /*= KNullDesC8*/,
   593 						         						  const TDesC8& aMimetype /*= KNullDesC8*/,
   607 						         						  TBool aIsAvatar /*= EFalse*/ )
   594 						         						  TBool aIsAvatar /*= EFalse*/ )
   608     {
   595     {
   609 	TRACE( T_LIT("CVIMPSTEnginePresenceSubService::PublishOwnPresenceL start"));
   596 	TRACER_AUTO;
   610     // Take handles to object factory and publish interface
   597     // Take handles to object factory and publish interface
   611     MPresencePublishing& publisher = iXimpEventObserver.XimpPresencePublishingL();
   598     MPresencePublishing& publisher = iXimpEventObserver.XimpPresencePublishingL();
   612 
   599 
   613     //Fill presence doc with presence components and attributes
   600     //Fill presence doc with presence components and attributes
   614     MPresenceInfo* myPresence = iXimpEventObserver.PresenceObjectFactoryL().NewPresenceInfoLC();//1
   601     MPresenceInfo* myPresence = iXimpEventObserver.PresenceObjectFactoryL().NewPresenceInfoLC();//1
   615     MPersonPresenceInfo *personPresence = iXimpEventObserver.PresenceObjectFactoryL().NewPersonPresenceInfoLC();//2
   602     MPersonPresenceInfo *personPresence = iXimpEventObserver.PresenceObjectFactoryL().NewPersonPresenceInfoLC();//2
   616     MPresenceInfoFieldCollection& attributeFields = personPresence->Fields();
   603     MPresenceInfoFieldCollection& attributeFields = personPresence->Fields();
   617 	
   604 	
   618  	MPresenceInfoField* infoField = NULL;
   605  	MPresenceInfoField* infoField = NULL;
   619 	TRACE( T_LIT("PublishOwnPresenceL aIsAvatar: %d"),  aIsAvatar );
   606  	TRACE( "aIsAvatar: %d",  aIsAvatar );
   620 	// avatar field set || clear
   607 	// avatar field set || clear
   621 	if ( aIsAvatar )
   608 	if ( aIsAvatar )
   622         {
   609         {
   623         TRACE( T_LIT(" PublishOwnPresenceL adding avatar field"));
   610 	TRACE( " PublishOwnPresenceL adding avatar field");
   624         
   611         
   625      	infoField = iXimpEventObserver.PresenceObjectFactoryL().NewInfoFieldLC();
   612      	infoField = iXimpEventObserver.PresenceObjectFactoryL().NewInfoFieldLC();
   626         MPresenceInfoFieldValueBinary* avatarField = iXimpEventObserver.PresenceObjectFactoryL().NewBinaryInfoFieldLC(); 
   613         MPresenceInfoFieldValueBinary* avatarField = iXimpEventObserver.PresenceObjectFactoryL().NewBinaryInfoFieldLC(); 
   627         TRACE( T_LIT(" PublishOwnPresenceL processing image data"));
   614         TRACE( " PublishOwnPresenceL processing image data");
   628         CVIMPSTEngineImageHandler* imageHandler = CVIMPSTEngineImageHandler::NewL();
   615         CVIMPSTEngineImageHandler* imageHandler = CVIMPSTEngineImageHandler::NewL();
   629         CleanupStack::PushL(imageHandler);
   616         CleanupStack::PushL(imageHandler);
   630         // get the avatar content from the image processor
   617         // get the avatar content from the image processor
   631         // returns image content if the  processing succesful 
   618         // returns image content if the  processing succesful 
   632         
   619         
   633         HBufC8* avatarContent = imageHandler->ProcessImageFromFileL( aFilename , aMimetype);
   620         HBufC8* avatarContent = imageHandler->ProcessImageFromFileL( aFilename , aMimetype);
   634         TRACE( T_LIT(" PublishOwnPresenceL processing image data completed "));
   621         TRACE( " PublishOwnPresenceL processing image data completed ");
   635         if ( avatarContent )
   622         if ( avatarContent )
   636 			{
   623 			{
   637 			TRACE( T_LIT("PublishOwnPresenceL valid image data found "));
   624         TRACE( "PublishOwnPresenceL valid image data found ");
   638 			CleanupStack::PushL(avatarContent);
   625 			CleanupStack::PushL(avatarContent);
   639 			// set a new avatar
   626 			// set a new avatar
   640 			avatarField->SetBinaryValueL(*avatarContent);
   627 			avatarField->SetBinaryValueL(*avatarContent);
   641  			avatarField->SetMimeTypeL(aMimetype);
   628  			avatarField->SetMimeTypeL(aMimetype);
   642 			CleanupStack::PopAndDestroy(); // avatarContent
   629 			CleanupStack::PopAndDestroy(); // avatarContent
   643 			}
   630 			}
   644 		else
   631 		else
   645 			{
   632 			{
   646 			TRACE( T_LIT("PublishOwnPresenceL NULL image data found "));
   633 		TRACE("PublishOwnPresenceL NULL image data found ");
   647 			//  clear the avatar 
   634 			//  clear the avatar 
   648 			avatarField->SetBinaryValueL(KNullDesC8);
   635 			avatarField->SetBinaryValueL(KNullDesC8);
   649 			iIsClearingAvatar = ETrue;  //set iIsClearingAvatar to ETrue
   636 			iIsClearingAvatar = ETrue;  //set iIsClearingAvatar to ETrue
   650 			}
   637 			}
   651         CleanupStack::PopAndDestroy(imageHandler); // imageHandler
   638         CleanupStack::PopAndDestroy(imageHandler); // imageHandler
   656        	infoField->SetFieldValue( avatarField );  // avatarField ownership transfered
   643        	infoField->SetFieldValue( avatarField );  // avatarField ownership transfered
   657         CleanupStack::Pop(); // avatarField
   644         CleanupStack::Pop(); // avatarField
   658 		attributeFields.AddOrReplaceFieldL(infoField ); // infofield ownership transfered
   645 		attributeFields.AddOrReplaceFieldL(infoField ); // infofield ownership transfered
   659         CleanupStack::Pop(); // infoField
   646         CleanupStack::Pop(); // infoField
   660 		infoField = NULL;
   647 		infoField = NULL;
   661 		TRACE( T_LIT(" PublishOwnPresenceL adding avatar field completed "));
   648 		TRACE( "adding avatar field completed ");
   662         }
   649         }
   663 
   650 
   664     // availabilty field
   651     // availabilty field
   665     infoField = iXimpEventObserver.PresenceObjectFactoryL().NewInfoFieldLC();//3
   652     infoField = iXimpEventObserver.PresenceObjectFactoryL().NewInfoFieldLC();//3
   666     //based on the state conver it to  ximpfw status.
   653     //based on the state conver it to  ximpfw status.
   698     // not own
   685     // not own
   699     CVIMPSTEngineRequestMapper* mapper = iXimpEventObserver.GetRequestMapper();
   686     CVIMPSTEngineRequestMapper* mapper = iXimpEventObserver.GetRequestMapper();
   700     mapper->CreateRequestL(reqId, ETrue,EVIMPSTXimpOperationPublisOwnPresence);// waite here
   687     mapper->CreateRequestL(reqId, ETrue,EVIMPSTXimpOperationPublisOwnPresence);// waite here
   701     TInt error = iXimpEventObserver.GetCompletedReqResult(); // get the result error
   688     TInt error = iXimpEventObserver.GetCompletedReqResult(); // get the result error
   702     CleanupStack::PopAndDestroy(1); // myPresence
   689     CleanupStack::PopAndDestroy(1); // myPresence
   703     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::PublishOwnPresenceL end "));
   690     
   704     return error;
   691     return error;
   705     }
   692     }
   706 
   693 
   707 // ---------------------------------------------------------
   694 // ---------------------------------------------------------
   708 // CVIMPSTEnginePresenceSubService::UpdateStatusToServerL
   695 // CVIMPSTEnginePresenceSubService::UpdateStatusToServerL
   709 // 
   696 // 
   710 // ---------------------------------------------------------    
   697 // ---------------------------------------------------------    
   711 NPresenceInfo::TAvailabilityValues CVIMPSTEnginePresenceSubService::ConvertPresenceStatus(TVIMPSTEnums::TOnlineStatus aStatus)
   698 NPresenceInfo::TAvailabilityValues CVIMPSTEnginePresenceSubService::ConvertPresenceStatus(TVIMPSTEnums::TOnlineStatus aStatus)
   712     {
   699     {
       
   700 	TRACER_AUTO;
   713     NPresenceInfo::TAvailabilityValues availablity;
   701     NPresenceInfo::TAvailabilityValues availablity;
   714     switch(aStatus)
   702     switch(aStatus)
   715         {
   703         {
   716         case TVIMPSTEnums::EOffline:
   704         case TVIMPSTEnums::EOffline:
   717             {
   705             {
   763 TInt  CVIMPSTEnginePresenceSubService::FetchPresenceFromCache()
   751 TInt  CVIMPSTEnginePresenceSubService::FetchPresenceFromCache()
   764     {
   752     {
   765     //TODO::Figure out how to get the service name.
   753     //TODO::Figure out how to get the service name.
   766     // passed the service id to see the member count
   754     // passed the service id to see the member count
   767     TInt error( KErrArgument );
   755     TInt error( KErrArgument );
   768     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::FetchPresenceFormCache() start") );
   756     TRACER_AUTO;
   769 	if( iServiceName )
   757 	if( iServiceName )
   770 		{
   758 		{
   771 		TPtr serviceNamePtr = iServiceName->Des();
   759 		TPtr serviceNamePtr = iServiceName->Des();
   772 		TRACE( T_LIT("CVIMPSTEnginePresenceSubService::FetchPresenceFormCache() - %S"), 
   760 		TRACE( "CVIMPSTEnginePresenceSubService::FetchPresenceFormCache() - %S", &serviceNamePtr );
   773 		        &serviceNamePtr );
       
   774 		// passed the service to register for notification
   761 		// passed the service to register for notification
   775 		error = iPresenceCacheReader->AllBuddiesPresenceInService(*iServiceName, this );		
   762 		error = iPresenceCacheReader->AllBuddiesPresenceInService(*iServiceName, this );		
   776 		}
   763 		}
   777 	TRACE( T_LIT("CVIMPSTEnginePresenceSubService::FetchPresenceFormCache() end") ); 
       
   778 	return error;
   764 	return error;
   779     }
   765     }
   780 
   766 
   781 // ---------------------------------------------------------------------------
   767 // ---------------------------------------------------------------------------
   782 // CVIMPSTEnginePresenceSubService::HandlePresenceReadL
   768 // CVIMPSTEnginePresenceSubService::HandlePresenceReadL
   783 // ---------------------------------------------------------------------------
   769 // ---------------------------------------------------------------------------
   784 //  
   770 //  
   785 void CVIMPSTEnginePresenceSubService::HandlePresenceReadL(TInt /*aErrorCode*/,
   771 void CVIMPSTEnginePresenceSubService::HandlePresenceReadL(TInt /*aErrorCode*/,
   786         RPointerArray<MPresenceBuddyInfo2>& aPresenceBuddyInfoList)
   772         RPointerArray<MPresenceBuddyInfo2>& aPresenceBuddyInfoList)
   787     {
   773     {
   788     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandlePresenceReadL start"));
   774 	TRACER_AUTO;
   789     // we have the ownership of  aPresenceBuddyInfoList : Push it to customize cleanupstack
   775     // we have the ownership of  aPresenceBuddyInfoList : Push it to customize cleanupstack
   790     // aPresenceBuddyInfoList is collection of owned object and each object need to be deleted
   776     // aPresenceBuddyInfoList is collection of owned object and each object need to be deleted
   791     CustomCleanupResetAndDestroyPushL(aPresenceBuddyInfoList);
   777     CustomCleanupResetAndDestroyPushL(aPresenceBuddyInfoList);
   792     MVIMPSTStorageServiceView* storage = 
   778     MVIMPSTStorageServiceView* storage = 
   793     				CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId);
   779     				CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId);
   794     TInt buddyCount = aPresenceBuddyInfoList.Count();
   780     TInt buddyCount = aPresenceBuddyInfoList.Count();
   795     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandlePresenceReadL - count: %d" ), buddyCount );
   781     TRACE( "count: %d" , buddyCount );
   796     for ( TInt i =0 ; i < buddyCount ; ++i)
   782     for ( TInt i =0 ; i < buddyCount ; ++i)
   797 		{
   783 		{
   798 		TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandlePresenceReadL - buddy index: %d" ), i );
   784     TRACE( " buddy index: %d" , i );
   799 		MPresenceBuddyInfo2* buddyinfo = aPresenceBuddyInfoList[i];
   785 		MPresenceBuddyInfo2* buddyinfo = aPresenceBuddyInfoList[i];
   800 		// read the buddyID : returns in XSP format
   786 		// read the buddyID : returns in XSP format
   801 		TPtrC buddyXSPId = buddyinfo->BuddyId();
   787 		TPtrC buddyXSPId = buddyinfo->BuddyId();
   802 		TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandlePresenceReadL - Status Message: %s" ), &buddyXSPId );
   788 		TRACE( "Status Message: %s" , &buddyXSPId );
   803 		TPtrC buddyId = buddyXSPId.Right( buddyXSPId.Length() - iServiceName->Length() - KColon().Length());
   789 		TPtrC buddyId = buddyXSPId.Right( buddyXSPId.Length() - iServiceName->Length() - KColon().Length());
   804 		// read the availability /presence state enum value 
   790 		// read the availability /presence state enum value 
   805 		MPresenceBuddyInfo2::TAvailabilityValues availabilityEnum = buddyinfo->Availability();
   791 		MPresenceBuddyInfo2::TAvailabilityValues availabilityEnum = buddyinfo->Availability();
   806 		TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandlePresenceReadL - Availability ENUM value: %d" ), availabilityEnum );
   792 		TRACE( "Availability ENUM value: %d" , availabilityEnum );
   807 		TPtrC avablityText = buddyinfo->AvailabilityText();
   793 		TPtrC avablityText = buddyinfo->AvailabilityText();
   808 		// convert the presence cache enum value to service tab enum 
   794 		// convert the presence cache enum value to service tab enum 
   809 		TVIMPSTEnums::TOnlineStatus status = ConvertPresenceCacheEnums( availabilityEnum , avablityText);
   795 		TVIMPSTEnums::TOnlineStatus status = ConvertPresenceCacheEnums( availabilityEnum , avablityText);
   810 		//  get the GetAnyFiled(which has only pending and blocked states.)
   796 		//  get the GetAnyFiled(which has only pending and blocked states.)
   811 		if(TVIMPSTEnums::EUnKnown == status)
   797 		if(TVIMPSTEnums::EUnKnown == status)
   812 			{
   798 			{
   813 			GetKeyFieldsAndValuesL(*buddyinfo,status);
   799 			GetKeyFieldsAndValuesL(*buddyinfo,status);
   814 			}
   800 			}
   815 		// read the  status message 
   801 		// read the  status message 
   816 		TPtrC statusMsg = buddyinfo->StatusMessage();
   802 		TPtrC statusMsg = buddyinfo->StatusMessage();
   817 		TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandlePresenceReadL - Status Message: %s" ), &statusMsg );
   803 		TRACE("Status Message: %s" , &statusMsg );
   818 		TPtrC8 avatarContent = buddyinfo->Avatar();
   804 		TPtrC8 avatarContent = buddyinfo->Avatar();
   819 		HBufC8* avatarScaledData = NULL;
   805 		HBufC8* avatarScaledData = NULL;
   820 		if ( avatarContent.Length() )
   806 		if ( avatarContent.Length() )
   821 			{
   807 			{
   822 			TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandlePresenceReadL - avatarContent Content available" ) );
   808 			TRACE( "avatarContent Content available"  );
   823 			CVIMPSTEngineImageHandler* imageHandler = CVIMPSTEngineImageHandler::NewL();
   809 			CVIMPSTEngineImageHandler* imageHandler = CVIMPSTEngineImageHandler::NewL();
   824 			CleanupStack::PushL(imageHandler);
   810 			CleanupStack::PushL(imageHandler);
   825 			TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandlePresenceReadL - imageHandler created " ) );
   811 			TRACE( "imageHandler created "  );
   826 		    avatarScaledData = imageHandler->ProcessImageFromDataL( avatarContent , KNullDesC8() );
   812 		    avatarScaledData = imageHandler->ProcessImageFromDataL( avatarContent , KNullDesC8() );
   827 		    TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandlePresenceReadL - ProcessImageFromDataL returned " ) );
   813 		    TRACE( "ProcessImageFromDataL returned " );
   828 			CleanupStack::PopAndDestroy();//imageHandler
   814 			CleanupStack::PopAndDestroy();//imageHandler
   829 			}
   815 			}
   830 		if( avatarScaledData && avatarScaledData->Length() )
   816 		if( avatarScaledData && avatarScaledData->Length() )
   831 			{
   817 			{
   832 			CleanupStack::PushL(avatarScaledData);
   818 			CleanupStack::PushL(avatarScaledData);
   839 			}
   825 			}
   840 		}
   826 		}
   841     aPresenceBuddyInfoList.ResetAndDestroy();
   827     aPresenceBuddyInfoList.ResetAndDestroy();
   842  
   828  
   843     CleanupStack::PopAndDestroy();  //  aPresenceBuddyInfoList
   829     CleanupStack::PopAndDestroy();  //  aPresenceBuddyInfoList
   844     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandlePresenceReadL end"));
       
   845     }
   830     }
   846 
   831 
   847 // ---------------------------------------------------------------------------
   832 // ---------------------------------------------------------------------------
   848 // CVIMPSTEnginePresenceSubService::HandlePresenceNotificationL
   833 // CVIMPSTEnginePresenceSubService::HandlePresenceNotificationL
   849 // ---------------------------------------------------------------------------
   834 // ---------------------------------------------------------------------------
   850 //  
   835 //  
   851 void CVIMPSTEnginePresenceSubService::HandlePresenceNotificationL(TInt /*aErrorCode*/,
   836 void CVIMPSTEnginePresenceSubService::HandlePresenceNotificationL(TInt /*aErrorCode*/,
   852         MPresenceBuddyInfo2* aPresenceBuddyInfo)
   837         MPresenceBuddyInfo2* aPresenceBuddyInfo)
   853     {
   838     {
   854     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandlePresenceNotificationL start"));    
   839 	TRACER_AUTO;
   855        
   840        
   856     if ( aPresenceBuddyInfo )
   841     if ( aPresenceBuddyInfo )
   857         {
   842         {
   858         CleanupDeletePushL( aPresenceBuddyInfo );
   843         CleanupDeletePushL( aPresenceBuddyInfo );
   859         DoHandlePresenceNotificationL(*aPresenceBuddyInfo);
   844         DoHandlePresenceNotificationL(*aPresenceBuddyInfo);
   860         CleanupStack::PopAndDestroy(1); // aPresenceBuddyInfo
   845         CleanupStack::PopAndDestroy(1); // aPresenceBuddyInfo
   861         
   846         
   862         }
   847         }
   863     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandlePresenceNotificationL end"));
       
   864     }
   848     }
   865 
   849 
   866 
   850 
   867 // ---------------------------------------------------------
   851 // ---------------------------------------------------------
   868 // CVIMPSTEnginePresenceSubService::SubscribeForAuthorizationL
   852 // CVIMPSTEnginePresenceSubService::SubscribeForAuthorizationL
   869 //  
   853 //  
   870 // ---------------------------------------------------------    
   854 // ---------------------------------------------------------    
   871 void  CVIMPSTEnginePresenceSubService::SubscribeForAuthorizationL()
   855 void  CVIMPSTEnginePresenceSubService::SubscribeForAuthorizationL()
   872     {
   856     {
       
   857 	TRACER_AUTO;
   873     TXIMPRequestId req;
   858     TXIMPRequestId req;
   874     MPresenceAuthorization& authorization = iXimpEventObserver.XimpAuthorizationL();
   859     MPresenceAuthorization& authorization = iXimpEventObserver.XimpAuthorizationL();
   875     req = authorization.SubscribePresenceGrantRequestListL();  
   860     req = authorization.SubscribePresenceGrantRequestListL();  
   876     // mapper is not own
   861     // mapper is not own
   877     CVIMPSTEngineRequestMapper* mapper = iXimpEventObserver.GetRequestMapper(); 
   862     CVIMPSTEngineRequestMapper* mapper = iXimpEventObserver.GetRequestMapper(); 
   883 // CVIMPSTEnginePresenceSubService::SendPresenceGrantPresentityResponseL
   868 // CVIMPSTEnginePresenceSubService::SendPresenceGrantPresentityResponseL
   884 //  
   869 //  
   885 // ---------------------------------------------------------    
   870 // ---------------------------------------------------------    
   886 TInt CVIMPSTEnginePresenceSubService::SendPresenceGrantPresentityL( const TDesC& aContactId , TBool aResponse )
   871 TInt CVIMPSTEnginePresenceSubService::SendPresenceGrantPresentityL( const TDesC& aContactId , TBool aResponse )
   887     {
   872     {
   888     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::SendPresenceGrantPresentityL stat"));  
   873 	TRACER_AUTO;
   889     __ASSERT_ALWAYS( aContactId.Length(), User::Leave( KErrArgument ) );
   874     __ASSERT_ALWAYS( aContactId.Length(), User::Leave( KErrArgument ) );
   890       
   875       
   891     // return the response to the server.    
   876     // return the response to the server.    
   892     MPresenceAuthorization& authorization = iXimpEventObserver.XimpAuthorizationL();
   877     MPresenceAuthorization& authorization = iXimpEventObserver.XimpAuthorizationL();
   893     // mapper is not own
   878     // mapper is not own
   922     if( ( ( error == KPREQUESTERRSUCCESSFUL) || ( error == KErrNone )  || iAutoAccept)  )
   907     if( ( ( error == KPREQUESTERRSUCCESSFUL) || ( error == KErrNone )  || iAutoAccept)  )
   923         {        
   908         {        
   924         MVIMPSTStorageServiceView* storage = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId) ;
   909         MVIMPSTStorageServiceView* storage = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId) ;
   925         if(storage && ( !storage->IsLocalStore() || iAutoAccept  ) && aResponse )
   910         if(storage && ( !storage->IsLocalStore() || iAutoAccept  ) && aResponse )
   926             {   
   911             {   
   927             TRACE( T_LIT("CVIMPSTEnginePresenceSubService::SendPresenceGrantPresentityL server store") );
   912         TRACE( " server store" );
   928             storage->CreateNewContactL( aContactId,KNullDesC, ETrue, iAutoAccept ); // ETrue is for invitation item 
   913             storage->CreateNewContactL( aContactId,KNullDesC, ETrue, iAutoAccept ); // ETrue is for invitation item 
   929             } 
   914             } 
   930         }
   915         }
   931     CleanupStack::PopAndDestroy(); //contactIdentity
   916     CleanupStack::PopAndDestroy(); //contactIdentity
   932     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::SendPresenceGrantPresentityL end"));
       
   933     return error;
   917     return error;
   934     }  
   918     }  
   935 // ---------------------------------------------------------
   919 // ---------------------------------------------------------
   936 // CVIMPSTEnginePresenceSubService::HandleSessionContextEventL
   920 // CVIMPSTEnginePresenceSubService::HandleSessionContextEventL
   937 // ---------------------------------------------------------
   921 // ---------------------------------------------------------
   938 void CVIMPSTEnginePresenceSubService::HandleSessionContextEventL(const MXIMPContext& aContext,
   922 void CVIMPSTEnginePresenceSubService::HandleSessionContextEventL(const MXIMPContext& aContext,
   939         const MXIMPBase& aEvent,
   923         const MXIMPBase& aEvent,
   940         TXimpOperation aXimpOperation /*= EVIMPSTXimpOperationNoOperation*/ )
   924         TXimpOperation aXimpOperation /*= EVIMPSTXimpOperationNoOperation*/ )
   941     {
   925     {
   942     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandleSessionContextEventL start"));
   926 	TRACER_AUTO;
   943     TInt32 eventId = aEvent.GetInterfaceId();
   927     TInt32 eventId = aEvent.GetInterfaceId();
   944 
   928 
   945     switch( aEvent.GetInterfaceId() )
   929     switch( aEvent.GetInterfaceId() )
   946         {
   930         {
   947         case MXIMPRequestCompleteEvent::KInterfaceId:
   931         case MXIMPRequestCompleteEvent::KInterfaceId:
   948             {
   932             {
   949             TRACE( T_LIT("InsideCallbackswitch::MXIMPRequestCompleteEvent"));
   933             TRACE( "MXIMPRequestCompleteEvent");
   950             //temp fix TBD
   934             //temp fix TBD
   951             //Only use the operations that u r intertest in
   935             //Only use the operations that u r intertest in
   952             if ( aXimpOperation <= EVIMPSTXimpOperationUnsubscribe )  
   936             if ( aXimpOperation <= EVIMPSTXimpOperationUnsubscribe )  
   953                 {
   937                 {
   954 
   938 
   958                 TRAP_IGNORE( HandleXimpRequestCompleteL( 
   942                 TRAP_IGNORE( HandleXimpRequestCompleteL( 
   959                         aXimpOperation,
   943                         aXimpOperation,
   960                         event->CompletionResult().ResultCode(),
   944                         event->CompletionResult().ResultCode(),
   961                         aEvent ) );
   945                         aEvent ) );
   962                 }
   946                 }
   963             TRACE( T_LIT("InsideCallback::HandlePresenceContextEvent"));    
   947             TRACE( "HandlePresenceContextEvent");  
   964 
   948 
   965             break;
   949             break;
   966             }
   950             }
   967         case MXIMPContextStateEvent::KInterfaceId:
   951         case MXIMPContextStateEvent::KInterfaceId:
   968             {
   952             {
   969             TRACE( T_LIT("InsideCallbackswitch::MXIMPContextStateEvent"));
   953             TRACE( "InsideCallbackswitch::MXIMPContextStateEvent");
   970             TRACE( T_LIT("InsideCallback::MXIMPContextStateEvent"));
   954             TRACE("InsideCallback::MXIMPContextStateEvent");
   971             break;
   955             break;
   972             }
   956             }
   973         case MPresentityGroupContentEvent::KInterfaceId:
   957         case MPresentityGroupContentEvent::KInterfaceId:
   974             {
   958             {
   975             TRACE( T_LIT("CVIMPSTEnginePresenceSubService::MPresentityGroupContentEvent"));
   959             TRACE( "MPresentityGroupContentEvent");
   976             DoHandlePresentityGroupContentEventL( aContext, aEvent );
   960             DoHandlePresentityGroupContentEventL( aContext, aEvent );
   977             TRACE( T_LIT("CVIMPSTEnginePresenceSubService::MPresentityGroupContentEvent"));
   961             TRACE( "MPresentityGroupContentEvent");
   978             break;  
   962             break;  
   979             }
   963             }
   980         case MPresenceGrantRequestListEvent::KInterfaceId:
   964         case MPresenceGrantRequestListEvent::KInterfaceId:
   981             {
   965             {
   982             TRACE( T_LIT("CVIMPSTEnginePresenceSubService::MPresenceGrantRequestListEvent"));
   966             TRACE( "MPresenceGrantRequestListEvent");
   983             DoHandlePresenceGrantRequestListEventL( aContext, aEvent );
   967             DoHandlePresenceGrantRequestListEventL( aContext, aEvent );
   984             TRACE( T_LIT("CVIMPSTEnginePresenceSubService::MPresenceGrantRequestListEvent"));
   968             TRACE( "MPresenceGrantRequestListEvent");
   985             break;
   969             break;
   986             }
   970             }
   987         case MPresenceBlockListEvent::KInterfaceId:
   971         case MPresenceBlockListEvent::KInterfaceId:
   988            {
   972            {
   989            TRACE( T_LIT("CVIMPSTEnginePresenceSubService::MPresenceBlockListEvent"));
   973            TRACE( "MPresenceBlockListEvent");
   990            DoHandlePresenceBlockListEventL( aContext, aEvent );
   974            DoHandlePresenceBlockListEventL( aContext, aEvent );
   991            TRACE( T_LIT("CVIMPSTEnginePresenceSubService::MPresenceBlockListEvent"));
   975            TRACE( "MPresenceBlockListEvent");
   992 
   976 
   993            break;
   977            break;
   994            }
   978            }
   995            
   979            
   996         default:
   980         default:
   997             {
   981             {
   998             break;
   982             break;
   999             }
   983             }
  1000         }
   984         }
  1001     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandleSessionContextEventL end"));   
       
  1002     }    
   985     }    
  1003 
   986 
  1004 // ---------------------------------------------------------------------------
   987 // ---------------------------------------------------------------------------
  1005 // CVIMPSTEnginePresenceSubService::HandleListEventCompleteL
   988 // CVIMPSTEnginePresenceSubService::HandleListEventCompleteL
  1006 // ---------------------------------------------------------------------------
   989 // ---------------------------------------------------------------------------
  1007 //
   990 //
  1008 void CVIMPSTEnginePresenceSubService::HandleListEventCompleteL(TXimpOperation aType,
   991 void CVIMPSTEnginePresenceSubService::HandleListEventCompleteL(TXimpOperation aType,
  1009         TInt aCompleteCode,
   992         TInt aCompleteCode,
  1010         const MXIMPBase& /*aEvent*/)
   993         const MXIMPBase& /*aEvent*/)
  1011     { 
   994     { 
  1012     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandleListEventCompleteL start"));
   995 	TRACER_AUTO;
  1013 
   996 
  1014     switch ( aType )
   997     switch ( aType )
  1015         {
   998         {
  1016         case EVIMPSTXimpOperationBind:
   999         case EVIMPSTXimpOperationBind:
  1017             {
  1000             {
  1053             break;
  1036             break;
  1054             }            
  1037             }            
  1055         default:
  1038         default:
  1056             break;   
  1039             break;   
  1057         }
  1040         }
  1058     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandleListEventCompleteL end"));    
       
  1059     }
  1041     }
  1060 
  1042 
  1061 // ---------------------------------------------------------------------------
  1043 // ---------------------------------------------------------------------------
  1062 // CVIMPSTEnginePresenceSubService::HandleXimpRequestCompleteL
  1044 // CVIMPSTEnginePresenceSubService::HandleXimpRequestCompleteL
  1063 // ---------------------------------------------------------------------------
  1045 // ---------------------------------------------------------------------------
  1064 //
  1046 //
  1065 void CVIMPSTEnginePresenceSubService::HandleXimpRequestCompleteL(TXimpOperation aType,
  1047 void CVIMPSTEnginePresenceSubService::HandleXimpRequestCompleteL(TXimpOperation aType,
  1066         TInt aCompleteCode,const MXIMPBase& aEvent )
  1048         TInt aCompleteCode,const MXIMPBase& aEvent )
  1067     {
  1049     {
  1068     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandleXimpRequestCompleteL start"));
  1050 	TRACER_AUTO;
  1069     switch ( aType )
  1051     switch ( aType )
  1070         {
  1052         {
  1071         case EVIMPSTXimpOperationBind:
  1053         case EVIMPSTXimpOperationBind:
  1072         case EVIMPSTXimpOperationGetSubscribedList:
  1054         case EVIMPSTXimpOperationGetSubscribedList:
  1073         case EVIMPSTXimpOperationGetBlockList:
  1055         case EVIMPSTXimpOperationGetBlockList:
  1088             break;
  1070             break;
  1089             }
  1071             }
  1090         }
  1072         }
  1091 
  1073 
  1092 
  1074 
  1093     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::HandleXimpRequestCompleteL end"));
       
  1094     }
  1075     }
  1095 // -----------------------------------------------------------------------------
  1076 // -----------------------------------------------------------------------------
  1096 // CVIMPSTEnginePresenceSubService::StoreToVirtualStoreL
  1077 // CVIMPSTEnginePresenceSubService::StoreToVirtualStoreL
  1097 // -----------------------------------------------------------------------------
  1078 // -----------------------------------------------------------------------------
  1098 //  
  1079 //  
  1099 void CVIMPSTEnginePresenceSubService::StoreToVirtualStoreL(
  1080 void CVIMPSTEnginePresenceSubService::StoreToVirtualStoreL(
  1100                             const MPresentityGroupContentEvent& aListEvent )
  1081                             const MPresentityGroupContentEvent& aListEvent )
  1101     {
  1082     {
  1102     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::StoreToVirtualStoreL start"));
  1083 	TRACER_AUTO;
  1103     TRACE( T_LIT("CurrentMembersCount count = %d"),aListEvent.CurrentMembersCount() );
  1084 	TRACE( " count = %d",aListEvent.CurrentMembersCount() );
  1104     TRACE( T_LIT("NewMembersCount count = %d"),aListEvent.NewMembersCount() );
  1085     TRACE("NewMembersCount count = %d",aListEvent.NewMembersCount() );
  1105     TRACE( T_LIT("UpdatedMembersCount count = %d"),aListEvent.UpdatedMembersCount() );
  1086     TRACE( "UpdatedMembersCount count = %d",aListEvent.UpdatedMembersCount() );
  1106     MVIMPSTStorageServiceView* storage = 
  1087     MVIMPSTStorageServiceView* storage = 
  1107     CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId) ;	
  1088     CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId) ;	
  1108     TLinearOrder< TPtrC > linearOrder (*CompareAlphabetically );
  1089     TLinearOrder< TPtrC > linearOrder (*CompareAlphabetically );
  1109     if (storage)
  1090     if (storage)
  1110         {		
  1091         {		
  1120             
  1101             
  1121             firstNameList.Reset();
  1102             firstNameList.Reset();
  1122             serviceField.Reset();
  1103             serviceField.Reset();
  1123             // number of contact in this list
  1104             // number of contact in this list
  1124            TInt currentMembrcount = aListEvent.CurrentMembersCount();
  1105            TInt currentMembrcount = aListEvent.CurrentMembersCount();
  1125            TRACE( T_LIT("currentMembrcount count = %d"),currentMembrcount );
  1106            TRACE( "currentMembrcount count = %d",currentMembrcount );
  1126             // Handle first current items
  1107             // Handle first current items
  1127             for(TInt j = 0; j < currentMembrcount ;j++ )
  1108             for(TInt j = 0; j < currentMembrcount ;j++ )
  1128                 {
  1109                 {
  1129                 const MPresentityGroupMemberInfo& memberInfo = 
  1110                 const MPresentityGroupMemberInfo& memberInfo = 
  1130                     aListEvent.CurrentMember( j ) ;
  1111                     aListEvent.CurrentMember( j ) ;
  1135                 firstNameList.AppendL(displayeName );
  1116                 firstNameList.AppendL(displayeName );
  1136                 }
  1117                 }
  1137 
  1118 
  1138             // number of contact in this list
  1119             // number of contact in this list
  1139             TInt newMembrcount = aListEvent.NewMembersCount() ;
  1120             TInt newMembrcount = aListEvent.NewMembersCount() ;
  1140             TRACE( T_LIT("newMembrcount count = %d"),newMembrcount );
  1121             TRACE("newMembrcount count = %d",newMembrcount );
  1141             for(TInt i = 0; i < newMembrcount ;i++ )
  1122             for(TInt i = 0; i < newMembrcount ;i++ )
  1142                 {
  1123                 {
  1143                 const MPresentityGroupMemberInfo& memberInfo = 
  1124                 const MPresentityGroupMemberInfo& memberInfo = 
  1144                 aListEvent.NewMember( i ) ;
  1125                 aListEvent.NewMember( i ) ;
  1145                 const MXIMPIdentity& memberIdentity = memberInfo.GroupMemberId() ;
  1126                 const MXIMPIdentity& memberIdentity = memberInfo.GroupMemberId() ;
  1149                 if(KErrAlreadyExists != error)
  1130                 if(KErrAlreadyExists != error)
  1150                     {
  1131                     {
  1151                     firstNameList.Append(displayeName);
  1132                     firstNameList.Append(displayeName);
  1152                     }
  1133                     }
  1153                 }
  1134                 }
  1154             TRACE( T_LIT(" calling CreateNewFetchContactsL") );
  1135             TRACE( " calling CreateNewFetchContactsL" );
  1155             TRACE( T_LIT(" serviceField count %d"),serviceField.Count());
  1136             TRACE( " serviceField count %d",serviceField.Count());
  1156             TRACE( T_LIT(" firstNameList count %d"),firstNameList.Count());
  1137             TRACE( " firstNameList count %d",firstNameList.Count());
  1157 
  1138 
  1158             // If count in both arrays does not match, storage side can panic
  1139             // If count in both arrays does not match, storage side can panic
  1159             __ASSERT_ALWAYS( firstNameList.Count() == serviceField.Count(), User::Leave( KErrCorrupt));
  1140             __ASSERT_ALWAYS( firstNameList.Count() == serviceField.Count(), User::Leave( KErrCorrupt));
  1160             storage->CreateNewFetchContactsL(firstNameList, serviceField);
  1141             storage->CreateNewFetchContactsL(firstNameList, serviceField);
  1161             iIsFetchingContact = EFalse;
  1142             iIsFetchingContact = EFalse;
  1189 		        const MPresentityGroupMemberInfo& memberInfo = 
  1170 		        const MPresentityGroupMemberInfo& memberInfo = 
  1190 		                                        aListEvent.NewMember( i ) ;
  1171 		                                        aListEvent.NewMember( i ) ;
  1191 		        const MXIMPIdentity& memberIdentity = memberInfo.GroupMemberId() ;
  1172 		        const MXIMPIdentity& memberIdentity = memberInfo.GroupMemberId() ;
  1192 		        TPtrC userId = memberIdentity.Identity();
  1173 		        TPtrC userId = memberIdentity.Identity();
  1193 		        TPtrC displayeName = memberInfo.GroupMemberDisplayName();
  1174 		        TPtrC displayeName = memberInfo.GroupMemberDisplayName();
  1194 		        TRACE( T_LIT("CVIMPSTEnginePresenceSubService: newMember %S"), &userId );	
  1175 		        TRACE( " newMember %S", &userId );
  1195 		        storage->CreateNewContactL(userId,displayeName,ETrue,ETrue); 	
  1176 		        storage->CreateNewContactL(userId,displayeName,ETrue,ETrue); 	
  1196 		        }
  1177 		        }
  1197 		   TInt removedMembrcount = aListEvent.DisappearedMembersCount() ;    
  1178 		   TInt removedMembrcount = aListEvent.DisappearedMembersCount() ;    
  1198 		   for(TInt i = 0; i < removedMembrcount ;i++ )
  1179 		   for(TInt i = 0; i < removedMembrcount ;i++ )
  1199 		        {
  1180 		        {
  1200 		        const MPresentityGroupMemberInfo& memberInfo = 
  1181 		        const MPresentityGroupMemberInfo& memberInfo = 
  1201 		                                        aListEvent.DisappearedMember( i ) ;
  1182 		                                        aListEvent.DisappearedMember( i ) ;
  1202 		        const MXIMPIdentity& memberIdentity = memberInfo.GroupMemberId() ;
  1183 		        const MXIMPIdentity& memberIdentity = memberInfo.GroupMemberId() ;
  1203 		        TPtrC userId = memberIdentity.Identity();
  1184 		        TPtrC userId = memberIdentity.Identity();
  1204 				TRACE( T_LIT("CVIMPSTEnginePresenceSubService: deleteMember %S"), &userId );
  1185 		        TRACE( "deleteMember %S", &userId );
  1205 		    	MVIMPSTStorageContact* contactExist = storage->FindContactByUserId(userId);
  1186 		    	MVIMPSTStorageContact* contactExist = storage->FindContactByUserId(userId);
  1206 		    	if(contactExist)
  1187 		    	if(contactExist)
  1207 		    	    {
  1188 		    	    {
  1208 		    	    storage->RemoveContactL(contactExist);	
  1189 		    	    storage->RemoveContactL(contactExist);	
  1209 		    	    }
  1190 		    	    }
  1210 		        }
  1191 		        }
  1211 			}
  1192 			}
  1212          
  1193          
  1213         }
  1194         }
  1214     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::StoreToVirtualStoreL end")); 
       
  1215     }
  1195     }
  1216 
  1196 
  1217 // ---------------------------------------------------------
  1197 // ---------------------------------------------------------
  1218 // CVIMPSTEnginePresenceSubService::IsChangeOwnStatusSupported
  1198 // CVIMPSTEnginePresenceSubService::IsChangeOwnStatusSupported
  1219 // 
  1199 // 
  1256 // CVIMPSTEnginePresenceSubService::ConvertXimpToClientPresenceStatus
  1236 // CVIMPSTEnginePresenceSubService::ConvertXimpToClientPresenceStatus
  1257 // ---------------------------------------------------------------------------
  1237 // ---------------------------------------------------------------------------
  1258 //  
  1238 //  
  1259 TVIMPSTEnums::TOnlineStatus CVIMPSTEnginePresenceSubService::ConvertPresenceCacheEnums(MPresenceBuddyInfo2::TAvailabilityValues aAvailabilityEnum,TPtrC aAvabilityText)
  1239 TVIMPSTEnums::TOnlineStatus CVIMPSTEnginePresenceSubService::ConvertPresenceCacheEnums(MPresenceBuddyInfo2::TAvailabilityValues aAvailabilityEnum,TPtrC aAvabilityText)
  1260     {
  1240     {
       
  1241 	TRACER_AUTO;
  1261     // convert the presence cache enums to UI enumvalues
  1242     // convert the presence cache enums to UI enumvalues
  1262     // by default if the enum doesnot match then its  TVIMPSTEnums::UnKnown
  1243     // by default if the enum doesnot match then its  TVIMPSTEnums::UnKnown
  1263     TVIMPSTEnums::TOnlineStatus status;
  1244     TVIMPSTEnums::TOnlineStatus status;
  1264     switch( aAvailabilityEnum )
  1245     switch( aAvailabilityEnum )
  1265         {
  1246         {
  1316 // ---------------------------------------------------------	
  1297 // ---------------------------------------------------------	
  1317 //TODO::Should be named as RegisterPresenceEventObserverL
  1298 //TODO::Should be named as RegisterPresenceEventObserverL
  1318 void CVIMPSTEnginePresenceSubService::RegisterPresenceEventObserverL(
  1299 void CVIMPSTEnginePresenceSubService::RegisterPresenceEventObserverL(
  1319         MVIMPSTEnginePresenceSubServiceEventObserver* aObserver)
  1300         MVIMPSTEnginePresenceSubServiceEventObserver* aObserver)
  1320     {
  1301     {
  1321     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::RegisterPresenceEventObserver start"));	
  1302 	TRACER_AUTO;
  1322     __ASSERT_ALWAYS( aObserver, User::Leave( KErrArgument ));		
  1303     __ASSERT_ALWAYS( aObserver, User::Leave( KErrArgument ));		
  1323     iSubServiceObserver = aObserver;
  1304     iSubServiceObserver = aObserver;
  1324     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::RegisterPresenceEventObserver end"));
       
  1325     }
  1305     }
  1326 
  1306 
  1327 // ---------------------------------------------------------
  1307 // ---------------------------------------------------------
  1328 // CVIMPSTEnginePresenceSubService::UnRegisterPresenceEventObserver
  1308 // CVIMPSTEnginePresenceSubService::UnRegisterPresenceEventObserver
  1329 // 
  1309 // 
  1330 // ---------------------------------------------------------	
  1310 // ---------------------------------------------------------	
  1331 
  1311 
  1332 void CVIMPSTEnginePresenceSubService::UnRegisterPresenceEventObserver(
  1312 void CVIMPSTEnginePresenceSubService::UnRegisterPresenceEventObserver(
  1333         MVIMPSTEnginePresenceSubServiceEventObserver* /*aObserver*/)
  1313         MVIMPSTEnginePresenceSubServiceEventObserver* /*aObserver*/)
  1334     {
  1314     {
  1335     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::UnRegisterPresenceEventObserver start"));
  1315 	TRACER_AUTO;
  1336     iSubServiceObserver = NULL;
  1316     iSubServiceObserver = NULL;
  1337     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::UnRegisterPresenceEventObserver end"));
       
  1338     }   
  1317     }   
  1339 // ---------------------------------------------------------------------------
  1318 // ---------------------------------------------------------------------------
  1340 // CVIMPSTEnginePresenceSubService::RetrieveBlockListL
  1319 // CVIMPSTEnginePresenceSubService::RetrieveBlockListL
  1341 // ---------------------------------------------------------------------------
  1320 // ---------------------------------------------------------------------------
  1342 //
  1321 //
  1343 void CVIMPSTEnginePresenceSubService::RetrieveBlockListL()
  1322 void CVIMPSTEnginePresenceSubService::RetrieveBlockListL()
  1344     {
  1323     {
  1345     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::RetrieveBlockListL start"));
  1324 	TRACER_AUTO;
  1346 
  1325 
  1347     //Subscribe block list
  1326     //Subscribe block list
  1348     // do get block list"));
  1327     // do get block list"));
  1349     TXIMPRequestId operationId = TXIMPRequestId::Null();
  1328     TXIMPRequestId operationId = TXIMPRequestId::Null();
  1350     operationId = iXimpEventObserver.XimpAuthorizationL().SubscribePresenceBlockListL();
  1329     operationId = iXimpEventObserver.XimpAuthorizationL().SubscribePresenceBlockListL();
  1351     CVIMPSTEngineRequestMapper* requestMapper =iXimpEventObserver.GetRequestMapper();
  1330     CVIMPSTEngineRequestMapper* requestMapper =iXimpEventObserver.GetRequestMapper();
  1352     requestMapper->CreateRequestL(operationId,EFalse,EVIMPSTXimpOperationGetBlockList);
  1331     requestMapper->CreateRequestL(operationId,EFalse,EVIMPSTXimpOperationGetBlockList);
  1353     // list retrieving ok. Waiting for list.;
  1332     // list retrieving ok. Waiting for list.;
  1354     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::RetrieveBlockListL end")); 
       
  1355     }
  1333     }
  1356 // ---------------------------------------------------------------------------
  1334 // ---------------------------------------------------------------------------
  1357 // CVIMPSTEnginePresenceSubService::DoHandlePresenceNotificationL
  1335 // CVIMPSTEnginePresenceSubService::DoHandlePresenceNotificationL
  1358 // ---------------------------------------------------------------------------
  1336 // ---------------------------------------------------------------------------
  1359 //
  1337 //
  1360 void CVIMPSTEnginePresenceSubService::DoHandlePresenceNotificationL(MPresenceBuddyInfo2& aPresenceBuddyInfo)
  1338 void CVIMPSTEnginePresenceSubService::DoHandlePresenceNotificationL(MPresenceBuddyInfo2& aPresenceBuddyInfo)
  1361     {
  1339     {
  1362     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceNotificationL start" ) );
  1340 	TRACER_AUTO;
  1363     MVIMPSTStorageServiceView* storage = 
  1341     MVIMPSTStorageServiceView* storage = 
  1364     						CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId);
  1342     						CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId);
  1365     TPtrC ownUserId = storage->OwnContactL().UserId();
  1343     TPtrC ownUserId = storage->OwnContactL().UserId();
  1366     // read the buddyID : returns in XSP format
  1344     // read the buddyID : returns in XSP format
  1367     TPtrC buddyXSPId = aPresenceBuddyInfo.BuddyId();
  1345     TPtrC buddyXSPId = aPresenceBuddyInfo.BuddyId();
  1368     TPtrC buddyId = buddyXSPId.Right( buddyXSPId.Length() - iServiceName->Length() - KColon().Length());
  1346     TPtrC buddyId = buddyXSPId.Right( buddyXSPId.Length() - iServiceName->Length() - KColon().Length());
  1369     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceNotificationL buddyId : %s" ), &buddyId );
  1347     TRACE( " buddyId : %s" , &buddyId );
  1370     // read the availability /presence state enum value 
  1348     // read the availability /presence state enum value 
  1371     MPresenceBuddyInfo2::TAvailabilityValues availabilityEnum = aPresenceBuddyInfo.Availability();
  1349     MPresenceBuddyInfo2::TAvailabilityValues availabilityEnum = aPresenceBuddyInfo.Availability();
  1372     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceNotificationL - Availability ENUM value: %d" ), availabilityEnum );
  1350     TRACE( "Availability ENUM value: %d" , availabilityEnum );
  1373     TPtrC avablityText = aPresenceBuddyInfo.AvailabilityText();
  1351     TPtrC avablityText = aPresenceBuddyInfo.AvailabilityText();
  1374     // convert the presence cache enum value to service tab enum 
  1352     // convert the presence cache enum value to service tab enum 
  1375     TVIMPSTEnums::TOnlineStatus status = ConvertPresenceCacheEnums( availabilityEnum, avablityText);
  1353     TVIMPSTEnums::TOnlineStatus status = ConvertPresenceCacheEnums( availabilityEnum, avablityText);
  1376     //TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceNotificationL - status: %d" ), status );
  1354     //TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceNotificationL - status: %d" ), status );
  1377     //check if its pending or blocked contact.
  1355     //check if its pending or blocked contact.
  1378     if(TVIMPSTEnums::EUnKnown == status)
  1356     if(TVIMPSTEnums::EUnKnown == status)
  1379         {
  1357         {
  1380         GetKeyFieldsAndValuesL(aPresenceBuddyInfo,status);
  1358         GetKeyFieldsAndValuesL(aPresenceBuddyInfo,status);
  1381         //TRACE( T_LIT("DoHandlePresenceNotificationL after GetKeyFieldsAndValuesL- status: %d" ), status );
  1359         //TRACE( T_LIT("DoHandlePresenceNotificationL after GetKeyFieldsAndValuesL- status: %d" ), status );
  1382         }
  1360         }
  1383     TRACE( T_LIT("DoHandlePresenceNotificationL - status: %d" ), status );
  1361     TRACE( " status: %d" , status );
  1384     // Read  the  status message 
  1362     // Read  the  status message 
  1385     TPtrC statusMsg = aPresenceBuddyInfo.StatusMessage();
  1363     TPtrC statusMsg = aPresenceBuddyInfo.StatusMessage();
  1386     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceNotificationL - Status Message: %s" ), &statusMsg );
  1364     TRACE("Status Message: %s" , &statusMsg );
  1387     TPtrC8 avatarContent = aPresenceBuddyInfo.Avatar();
  1365     TPtrC8 avatarContent = aPresenceBuddyInfo.Avatar();
  1388     
  1366     
  1389     ////////////////////////////////////////////////////////////////
  1367     ////////////////////////////////////////////////////////////////
  1390     HBufC8* avatarScaledData = NULL;
  1368     HBufC8* avatarScaledData = NULL;
  1391 	if ( avatarContent.Length() )
  1369 	if ( avatarContent.Length() )
  1392 		{
  1370 		{
  1393 		TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceNotificationL - avatarContent Content available" ) );
  1371 	TRACE( "avatarContent Content available" );
  1394 		CVIMPSTEngineImageHandler* imageHandler = CVIMPSTEngineImageHandler::NewL();
  1372 		CVIMPSTEngineImageHandler* imageHandler = CVIMPSTEngineImageHandler::NewL();
  1395 		CleanupStack::PushL(imageHandler);
  1373 		CleanupStack::PushL(imageHandler);
  1396 		TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceNotificationL - imageHandler created " ) );
  1374 		TRACE( "imageHandler created " );
  1397 		avatarScaledData = imageHandler->ProcessImageFromDataL( avatarContent , KNullDesC8() );
  1375 		avatarScaledData = imageHandler->ProcessImageFromDataL( avatarContent , KNullDesC8() );
  1398 		TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceNotificationL - ProcessImageFromDataL returned " ) );
  1376 		TRACE( " ProcessImageFromDataL returned " );
  1399 		CleanupStack::PopAndDestroy();//imageHandler
  1377 		CleanupStack::PopAndDestroy();//imageHandler
  1400 		}
  1378 		}
  1401     if( avatarScaledData && avatarScaledData->Length())
  1379     if( avatarScaledData && avatarScaledData->Length())
  1402         {
  1380         {
  1403         CleanupStack::PushL(avatarScaledData);
  1381         CleanupStack::PushL(avatarScaledData);
  1411         }
  1389         }
  1412     else
  1390     else
  1413         {
  1391         {
  1414         storage->UpdatePresenceL(buddyId, status, statusMsg, KNullDesC8 );      
  1392         storage->UpdatePresenceL(buddyId, status, statusMsg, KNullDesC8 );      
  1415         }
  1393         }
  1416 	TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceNotificationL end" ) );
       
  1417     }
  1394     }
  1418 // ---------------	------------------------------------------------------------
  1395 // ---------------	------------------------------------------------------------
  1419 // CVIMPSTEnginePresenceSubService::
  1396 // CVIMPSTEnginePresenceSubService::
  1420 //      DoHandlePresentityGroupContentEventL
  1397 //      DoHandlePresentityGroupContentEventL
  1421 // ---------------------------------------------------------------------------
  1398 // ---------------------------------------------------------------------------
  1422 //
  1399 //
  1423 void CVIMPSTEnginePresenceSubService::DoHandlePresenceBlockListEventL(
  1400 void CVIMPSTEnginePresenceSubService::DoHandlePresenceBlockListEventL(
  1424                                                         const MXIMPContext& /*aContext*/,
  1401                                                         const MXIMPContext& /*aContext*/,
  1425                                                         const MXIMPBase& aEvent )
  1402                                                         const MXIMPBase& aEvent )
  1426     {
  1403     {
  1427     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceBlockListEventL start"));
  1404 	TRACER_AUTO;
  1428     const MPresenceBlockListEvent& event  =
  1405     const MPresenceBlockListEvent& event  =
  1429         *TXIMPGetInterface< const MPresenceBlockListEvent >::From( 
  1406         *TXIMPGetInterface< const MPresenceBlockListEvent >::From( 
  1430             aEvent,
  1407             aEvent,
  1431             MXIMPBase::EPanicIfUnknown );
  1408             MXIMPBase::EPanicIfUnknown );
  1432     // if the feature is supported then we need to add this contact into virtual store.
  1409     // if the feature is supported then we need to add this contact into virtual store.
  1433     // that logic  needs to be implemented.
  1410     // that logic  needs to be implemented.
  1434     // inform ui about the state change from updatingcontacts to registered.
  1411     // inform ui about the state change from updatingcontacts to registered.
  1435     if(TVIMPSTEnums::ESVCEUpdatingContacts == iServiceState )
  1412     if(TVIMPSTEnums::ESVCEUpdatingContacts == iServiceState )
  1436         {
  1413         {
  1437         TRACE( T_LIT(" -> CVIMPSTEnginePresenceSubService:state is ESVCEUpdatingContacts" ));  
  1414     TRACE( " -> DoHandlePresentityGroupContentEventL:state is ESVCEUpdatingContacts" );
  1438         }
  1415         }
  1439         
  1416         
  1440     TRACE( T_LIT(" -> new member count: %d" ), event.NewBlocksCount());    
  1417     TRACE( " new member count: %d" , event.NewBlocksCount());  
  1441 
  1418 
  1442     TInt subscriptionCount  =  event.NewBlocksCount();
  1419     TInt subscriptionCount  =  event.NewBlocksCount();
  1443 
  1420 
  1444     TRACE( T_LIT(" -> subscriptionCount: %d"), subscriptionCount );
  1421     TRACE(" subscriptionCount: %d", subscriptionCount );
  1445 
  1422 
  1446         TRACE( T_LIT(" -> handling buddy list" ) );    
  1423         TRACE( "  handling buddy list"  ); 
  1447         HBufC* subsbuf(NULL);        
  1424         HBufC* subsbuf(NULL);        
  1448         for( TInt i =0; i < subscriptionCount; i++ )
  1425         for( TInt i =0; i < subscriptionCount; i++ )
  1449             {
  1426             {
  1450             const MPresenceBlockInfo& blockedEntitys = event.NewBlock(i);
  1427             const MPresenceBlockInfo& blockedEntitys = event.NewBlock(i);
  1451             const MXIMPIdentity& ident = blockedEntitys.BlockedEntityId();
  1428             const MXIMPIdentity& ident = blockedEntitys.BlockedEntityId();
  1452             subsbuf = ident.Identity().AllocLC();
  1429             subsbuf = ident.Identity().AllocLC();
  1453             TPtr subsbufPtr = subsbuf->Des();
  1430             TPtr subsbufPtr = subsbuf->Des();
  1454             TRACE( T_LIT(" -> identity: %S"), &subsbufPtr );    
  1431             TRACE( " -> identity: %S", &subsbufPtr );   
  1455 
  1432 
  1456             TRACE( T_LIT(" -> subscribe to cache" ) );    
  1433             TRACE(" -> subscribe to cache"  );    
  1457             SubscribePresenceOfSingleContactL(*subsbuf);
  1434             SubscribePresenceOfSingleContactL(*subsbuf);
  1458             iBlockedListMgr->AddToBlockedListL(*subsbuf);
  1435             iBlockedListMgr->AddToBlockedListL(*subsbuf);
  1459             CleanupStack::PopAndDestroy( subsbuf );
  1436             CleanupStack::PopAndDestroy( subsbuf );
  1460             }
  1437             }
  1461         TInt disappearedCount = event.DisappearedBlocksCount();  
  1438         TInt disappearedCount = event.DisappearedBlocksCount();  
  1464                 {
  1441                 {
  1465                 const MPresenceBlockInfo& blockedEntitys = event.DisappearedBlock( j );
  1442                 const MPresenceBlockInfo& blockedEntitys = event.DisappearedBlock( j );
  1466                 const MXIMPIdentity& ident = blockedEntitys.BlockedEntityId();
  1443                 const MXIMPIdentity& ident = blockedEntitys.BlockedEntityId();
  1467                 subsbuf = ident.Identity().AllocLC();
  1444                 subsbuf = ident.Identity().AllocLC();
  1468                 TPtr subsbufPtr = subsbuf->Des();
  1445                 TPtr subsbufPtr = subsbuf->Des();
  1469                 TRACE( T_LIT(" -> identity: %S"), &subsbufPtr );    
  1446                 TRACE( " identity: %S", &subsbufPtr );
  1470               
  1447               
  1471                 iBlockedListMgr->RemoveFromBlockListL( *subsbuf );    
  1448                 iBlockedListMgr->RemoveFromBlockListL( *subsbuf );    
  1472                 
  1449                 
  1473             CleanupStack::PopAndDestroy( subsbuf );
  1450             CleanupStack::PopAndDestroy( subsbuf );
  1474             }
  1451             }
  1476         if(iBlockedListObserver)
  1453         if(iBlockedListObserver)
  1477 	        {
  1454 	        {
  1478 	        iBlockedListObserver->HandleBlockedListFetchCompleteL();
  1455 	        iBlockedListObserver->HandleBlockedListFetchCompleteL();
  1479 	        iBlockListFetchReqPending = EFalse;
  1456 	        iBlockListFetchReqPending = EFalse;
  1480 	        }
  1457 	        }
  1481     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::DoHandlePresenceBlockListEventL end"));
       
  1482 
  1458 
  1483     }
  1459     }
  1484 
  1460 
  1485 // ---------------------------------------------------------------------------
  1461 // ---------------------------------------------------------------------------
  1486 // CVIMPSTEnginePresenceSubService::AddToBlockListL
  1462 // CVIMPSTEnginePresenceSubService::AddToBlockListL
  1487 // ---------------------------------------------------------------------------
  1463 // ---------------------------------------------------------------------------
  1488 //
  1464 //
  1489 TInt CVIMPSTEnginePresenceSubService::AddToBlockListL( const TDesC& aContactId )
  1465 TInt CVIMPSTEnginePresenceSubService::AddToBlockListL( const TDesC& aContactId )
  1490     {
  1466     {
  1491     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::AddToBlockListL start"));
  1467 	TRACER_AUTO;
  1492     if(TVIMPSTEnums::ESVCERegistered != iServiceState)
  1468     if(TVIMPSTEnums::ESVCERegistered != iServiceState)
  1493        return KErrNotSupported;
  1469        return KErrNotSupported;
  1494     //if aContactId is zero.
  1470     //if aContactId is zero.
  1495     if( 0 == aContactId.Length())
  1471     if( 0 == aContactId.Length())
  1496        return KErrArgument;
  1472        return KErrArgument;
  1497     
  1473     
  1498     TRACE( T_LIT(" -> aContactId: %s" ), &aContactId);
  1474     TRACE( " aContactId: %s" , &aContactId);
  1499     TRACE( T_LIT(" -> perform block operation" ) );      
  1475     TRACE( " perform block operation" ); 
  1500     
  1476     
  1501     MXIMPIdentity* identity = iXimpEventObserver.XimpPresenceContextL().ObjectFactory().NewIdentityLC();
  1477     MXIMPIdentity* identity = iXimpEventObserver.XimpPresenceContextL().ObjectFactory().NewIdentityLC();
  1502     
  1478     
  1503     identity->SetIdentityL( aContactId ); 
  1479     identity->SetIdentityL( aContactId ); 
  1504 
  1480 
  1514     		CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId);
  1490     		CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId);
  1515 		storage->UpdateAvatarL(aContactId,KNullDesC8);
  1491 		storage->UpdateAvatarL(aContactId,KNullDesC8);
  1516 	    }
  1492 	    }
  1517     //when pres. cache call will come.
  1493     //when pres. cache call will come.
  1518     CleanupStack::PopAndDestroy(); // identity    
  1494     CleanupStack::PopAndDestroy(); // identity    
  1519     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::AddToBlockListL end"));
       
  1520     return error;
  1495     return error;
  1521     }
  1496     }
  1522 
  1497 
  1523 // ---------------------------------------------------------------------------
  1498 // ---------------------------------------------------------------------------
  1524 // CVIMPSTEnginePresenceSubService::RemoveFromBlockListL
  1499 // CVIMPSTEnginePresenceSubService::RemoveFromBlockListL
  1525 // ---------------------------------------------------------------------------
  1500 // ---------------------------------------------------------------------------
  1526 //
  1501 //
  1527 TInt CVIMPSTEnginePresenceSubService::RemoveFromBlockListL( const TDesC& aUriOfTheContact )
  1502 TInt CVIMPSTEnginePresenceSubService::RemoveFromBlockListL( const TDesC& aUriOfTheContact )
  1528     {
  1503     {
  1529     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::RemoveFromBlockListL start"));
  1504 	TRACER_AUTO;
  1530     if(TVIMPSTEnums::ESVCERegistered != iServiceState)
  1505     if(TVIMPSTEnums::ESVCERegistered != iServiceState)
  1531        return KErrNotSupported;
  1506        return KErrNotSupported;
  1532     //if aUriOfTheCOntact is zero.
  1507     //if aUriOfTheCOntact is zero.
  1533     if( 0 == aUriOfTheContact.Length())
  1508     if( 0 == aUriOfTheContact.Length())
  1534        return KErrNotFound;
  1509        return KErrNotFound;
  1535     
  1510     
  1536     TRACE( T_LIT(" -> aUriOfTheContact: %s" ), &aUriOfTheContact);
  1511     TRACE(" -> aUriOfTheContact: %s" , &aUriOfTheContact);
  1537     TRACE( T_LIT(" -> perform unblock operation" ) );      
  1512     TRACE( " -> perform unblock operation"  );  
  1538     
  1513     
  1539     MXIMPIdentity* identity = iXimpEventObserver.XimpPresenceContextL().ObjectFactory().NewIdentityLC();
  1514     MXIMPIdentity* identity = iXimpEventObserver.XimpPresenceContextL().ObjectFactory().NewIdentityLC();
  1540     identity->SetIdentityL( aUriOfTheContact ); 
  1515     identity->SetIdentityL( aUriOfTheContact ); 
  1541    
  1516    
  1542     TXIMPRequestId reqId = iXimpEventObserver.XimpAuthorizationL().CancelPresenceBlockFromPresentityL(*identity );
  1517     TXIMPRequestId reqId = iXimpEventObserver.XimpAuthorizationL().CancelPresenceBlockFromPresentityL(*identity );
  1549 	    {
  1524 	    {
  1550 	    iBlockedListMgr->RemoveFromBlockListL(aUriOfTheContact);
  1525 	    iBlockedListMgr->RemoveFromBlockListL(aUriOfTheContact);
  1551 	    }
  1526 	    }
  1552     CleanupStack::PopAndDestroy( 1 ); // identity    
  1527     CleanupStack::PopAndDestroy( 1 ); // identity    
  1553     
  1528     
  1554     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::RemoveFromBlockListL end"));
       
  1555     return error;
  1529     return error;
  1556     }
  1530     }
  1557     
  1531     
  1558 // ---------------------------------------------------------------------------
  1532 // ---------------------------------------------------------------------------
  1559 // CVIMPSTEnginePresenceSubService::GetBlockedList
  1533 // CVIMPSTEnginePresenceSubService::GetBlockedList
  1581 // CVIMPSTEnginePresenceSubService::FetchBlockedListFromServer
  1555 // CVIMPSTEnginePresenceSubService::FetchBlockedListFromServer
  1582 // ---------------------------------------------------------------------------
  1556 // ---------------------------------------------------------------------------
  1583 //
  1557 //
  1584 void CVIMPSTEnginePresenceSubService::FetchBlockedListFromServerL(MVIMPSTEngineBlockedListFetchEventObserver* aOb)
  1558 void CVIMPSTEnginePresenceSubService::FetchBlockedListFromServerL(MVIMPSTEngineBlockedListFetchEventObserver* aOb)
  1585 	{
  1559 	{
       
  1560 	TRACER_AUTO;
  1586 	if(EFalse == iBlockListFetchReqPending)
  1561 	if(EFalse == iBlockListFetchReqPending)
  1587 		{
  1562 		{
  1588 		//set the observer to give call back; Fetch from server is completed.
  1563 		//set the observer to give call back; Fetch from server is completed.
  1589 		iBlockedListObserver = aOb;
  1564 		iBlockedListObserver = aOb;
  1590 	
  1565 	
  1605 // CVIMPSTEnginePresenceSubService::GetKeyFieldsAndValuesL
  1580 // CVIMPSTEnginePresenceSubService::GetKeyFieldsAndValuesL
  1606 // ---------------------------------------------------------------------------
  1581 // ---------------------------------------------------------------------------
  1607 //
  1582 //
  1608 void CVIMPSTEnginePresenceSubService::GetKeyFieldsAndValuesL(MPresenceBuddyInfo2& aPresenceBuddyInfo,TVIMPSTEnums::TOnlineStatus &aStatus)
  1583 void CVIMPSTEnginePresenceSubService::GetKeyFieldsAndValuesL(MPresenceBuddyInfo2& aPresenceBuddyInfo,TVIMPSTEnums::TOnlineStatus &aStatus)
  1609     {
  1584     {
       
  1585 	TRACER_AUTO;
  1610     TPtrC8 value = aPresenceBuddyInfo.GetAnyField( KExtensionKey());
  1586     TPtrC8 value = aPresenceBuddyInfo.GetAnyField( KExtensionKey());
  1611     // At any point of time fro remote and blocked contact only one of the keys
  1587     // At any point of time fro remote and blocked contact only one of the keys
  1612     // KPendingRequestExtensionValue/KBlockedExtensionValue will be assigned, and not both the keys.
  1588     // KPendingRequestExtensionValue/KBlockedExtensionValue will be assigned, and not both the keys.
  1613     if(value.Compare( KPendingRequestExtensionValue ) == 0)
  1589     if(value.Compare( KPendingRequestExtensionValue ) == 0)
  1614         {
  1590         {
  1636 // CVIMPSTEnginePresenceSubService::UpdatePresenceStateL
  1612 // CVIMPSTEnginePresenceSubService::UpdatePresenceStateL
  1637 // ---------------------------------------------------------------------------
  1613 // ---------------------------------------------------------------------------
  1638 //
  1614 //
  1639 void CVIMPSTEnginePresenceSubService::UpdatePresenceStateL()
  1615 void CVIMPSTEnginePresenceSubService::UpdatePresenceStateL()
  1640     {
  1616     {
  1641     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::UpdatePresenceStateL start") );
  1617 	TRACER_AUTO;
  1642     //inform ui about the state change from updatingcontacts to registered.
  1618     //inform ui about the state change from updatingcontacts to registered.
  1643     iServiceState = TVIMPSTEnums::ESVCERegistered;    
  1619     iServiceState = TVIMPSTEnums::ESVCERegistered;    
  1644     iObserver.HandleServceConnectionEventL();
  1620     iObserver.HandleServceConnectionEventL();
  1645     
  1621     
  1646     TRACE( T_LIT(" -> HandleContactFetchedL:state is ESVCERegistered" )); 
  1622     TRACE( " -> HandleContactFetchedL:state is ESVCERegistered" ); 
  1647     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::UpdatePresenceStateL end"));
       
  1648     }
  1623     }
  1649 
  1624 
  1650 // ---------------------------------------------------------------------------
  1625 // ---------------------------------------------------------------------------
  1651 // CVIMPSTEnginePresenceSubService::FetchPresenceOfSingleContactL
  1626 // CVIMPSTEnginePresenceSubService::FetchPresenceOfSingleContactL
  1652 // ---------------------------------------------------------------------------
  1627 // ---------------------------------------------------------------------------
  1653 //
  1628 //
  1654 void CVIMPSTEnginePresenceSubService::FetchPresenceOfSingleContactL(const TDesC& aContact)
  1629 void CVIMPSTEnginePresenceSubService::FetchPresenceOfSingleContactL(const TDesC& aContact)
  1655     {
  1630     {
  1656     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::FetchPresenceOfSingleContactL Start"));  
  1631 	TRACER_AUTO;
  1657     if(aContact.Length() && iServiceName->Length())
  1632     if(aContact.Length() && iServiceName->Length())
  1658         {
  1633         {
  1659         HBufC* name = HBufC::NewLC( iServiceName->Length() + KColon().Length() + aContact.Length()  ); // 1. on to cleanup stack
  1634         HBufC* name = HBufC::NewLC( iServiceName->Length() + KColon().Length() + aContact.Length()  ); // 1. on to cleanup stack
  1660         TPtr namePtr( name->Des() );
  1635         TPtr namePtr( name->Des() );
  1661         namePtr.Zero();
  1636         namePtr.Zero();
  1662         // append the service name followed by user id ,seperated by colon
  1637         // append the service name followed by user id ,seperated by colon
  1663         namePtr.Append(*iServiceName);
  1638         namePtr.Append(*iServiceName);
  1664         namePtr.Append(KColon);
  1639         namePtr.Append(KColon);
  1665         namePtr.Append(aContact);
  1640         namePtr.Append(aContact);
  1666         TRACE( T_LIT("CVIMPSTEnginePresenceSubService::FetchPresenceOfSingleContactL namePtr = %S"), &namePtr);  
  1641         TRACE( " namePtr = %S", &namePtr);  
  1667         MPresenceBuddyInfo2* presenceBuddyInfo = iPresenceCacheReader->PresenceInfoLC(namePtr); // 2. on to cleanupstack
  1642         MPresenceBuddyInfo2* presenceBuddyInfo = iPresenceCacheReader->PresenceInfoLC(namePtr); // 2. on to cleanupstack
  1668         if ( presenceBuddyInfo )
  1643         if ( presenceBuddyInfo )
  1669             {
  1644             {
  1670             TRACE( T_LIT("CVIMPSTEnginePresenceSubService::FetchPresenceOfSingleContactL presenceBuddyInfo"));            
  1645         TRACE("presenceBuddyInfo");            
  1671             DoHandlePresenceNotificationL(*presenceBuddyInfo);
  1646             DoHandlePresenceNotificationL(*presenceBuddyInfo);
  1672             CleanupStack::PopAndDestroy();  // presenceBuddyInfo
  1647             CleanupStack::PopAndDestroy();  // presenceBuddyInfo
  1673             TRACE( T_LIT("CVIMPSTEnginePresenceSubService::FetchPresenceOfSingleContactL presenceBuddyInfo end"));  
  1648             TRACE("presenceBuddyInfo end");  
  1674             }
  1649             }
  1675         CleanupStack::PopAndDestroy(name);  // name
  1650         CleanupStack::PopAndDestroy(name);  // name
  1676         }
  1651         }
  1677     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::FetchPresenceOfSingleContactL End")); 
       
  1678     }
  1652     }
  1679 
  1653 
  1680 // ---------------------------------------------------------------------------
  1654 // ---------------------------------------------------------------------------
  1681 // CVIMPSTEnginePresenceSubService::UnsubscribeListsL
  1655 // CVIMPSTEnginePresenceSubService::UnsubscribeListsL
  1682 // ---------------------------------------------------------------------------
  1656 // ---------------------------------------------------------------------------
  1683 //
  1657 //
  1684 void CVIMPSTEnginePresenceSubService::UnsubscribeListsL()
  1658 void CVIMPSTEnginePresenceSubService::UnsubscribeListsL()
  1685     {
  1659     {
  1686     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::UnsubscribeListsL IN"));
  1660     TRACER_AUTO;
  1687     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::UnsubscribeListsL - unsubscribe buddy list"));
       
  1688 
  1661 
  1689     // It is assumed here that buddy list and authorization list has been always
  1662     // It is assumed here that buddy list and authorization list has been always
  1690     // subscribed if bind has been done. Caller of this function must check
  1663     // subscribed if bind has been done. Caller of this function must check
  1691     // that session has been bound before calling this.
  1664     // that session has been bound before calling this.
  1692     TBuf<KUriMaxLength> buddyGroupBuffer( KFriendList );
  1665     TBuf<KUriMaxLength> buddyGroupBuffer( KFriendList );
  1698     CleanupStack::PopAndDestroy(); // buddyGroupList
  1671     CleanupStack::PopAndDestroy(); // buddyGroupList
  1699            
  1672            
  1700    // Auth list
  1673    // Auth list
  1701    if(iSubscribeToAuthList)
  1674    if(iSubscribeToAuthList)
  1702        {
  1675        {
  1703        TRACE( T_LIT("CVIMPSTEnginePresenceSubService::UnsubscribeListsL - unsubscribe auth list"));
  1676        TRACE("unsubscribe auth list");
  1704        iSubscribeToAuthList = EFalse;
  1677        iSubscribeToAuthList = EFalse;
  1705       iXimpEventObserver.XimpAuthorizationL().UnsubscribePresenceGrantRequestListL();  
  1678       iXimpEventObserver.XimpAuthorizationL().UnsubscribePresenceGrantRequestListL();  
  1706        }
  1679        }
  1707  
  1680  
  1708    // block list
  1681    // block list
  1709    TRACE( T_LIT("CVIMPSTEnginePresenceSubService::UnsubscribeListsL - check if block is supported"));
  1682    TRACE( "check if block is supported");
  1710    TInt supportedFeatures = iXimpEventObserver.GetSupportedFeatures();
  1683    TInt supportedFeatures = iXimpEventObserver.GetSupportedFeatures();
  1711    if ( (EVIMPSTFeatureBlock & supportedFeatures) && (EVIMPSTFeatureUnBlock & supportedFeatures) )
  1684    if ( (EVIMPSTFeatureBlock & supportedFeatures) && (EVIMPSTFeatureUnBlock & supportedFeatures) )
  1712        {
  1685        {
  1713        TRACE( T_LIT("CVIMPSTEnginePresenceSubService::UnsubscribeListsL - unsubscribe block list"));
  1686        TRACE( "unsubscribe block list");
  1714        iXimpEventObserver.XimpAuthorizationL().UnsubscribePresenceBlockListL();        
  1687        iXimpEventObserver.XimpAuthorizationL().UnsubscribePresenceBlockListL();        
  1715        }
  1688        }
  1716     TRACE( T_LIT("CVIMPSTEnginePresenceSubService::UnsubscribeListsL OUT"));
  1689     
  1717     }
  1690     }
  1718 
  1691 
  1719 // End of file
  1692 // End of file