simpledatamodeladapter/src/presenceplugingroup.cpp
branchRCL_3
changeset 25 e53c01f160bc
parent 8 aca99fb8a3dd
equal deleted inserted replaced
19:10246e066a50 25:e53c01f160bc
    37 #include "presenceplugincommon.h"
    37 #include "presenceplugincommon.h"
    38 #include "presencepluginvirtualgroup.h"
    38 #include "presencepluginvirtualgroup.h"
    39 #include "presenceplugindata.h"
    39 #include "presenceplugindata.h"
    40 #include "presencepluginwatcher.h"
    40 #include "presencepluginwatcher.h"
    41 #include "presencepluginauthorization.h"
    41 #include "presencepluginauthorization.h"
       
    42 #include "presencepluginutility.h"
    42 
    43 
    43 // ======== MEMBER FUNCTIONS ========
    44 // ======== MEMBER FUNCTIONS ========
    44 
    45 
    45 // ---------------------------------------------------------------------------
    46 // ---------------------------------------------------------------------------
    46 // CPresencePluginGroups::CPresencePluginGroups
    47 // CPresencePluginGroups::CPresencePluginGroups
   218     iXIMPId = aReqId;
   219     iXIMPId = aReqId;
   219         
   220         
   220     if( !aGroupId.Identity().Compare( KPresenceBuddyList ) )
   221     if( !aGroupId.Identity().Compare( KPresenceBuddyList ) )
   221         {
   222         {
   222         DP_SDA("CPresencePluginGroups::DoAddPresentityGroupMemberL - buddylist");
   223         DP_SDA("CPresencePluginGroups::DoAddPresentityGroupMemberL - buddylist");
   223         iOperation = EAddPresentityGroupMember;
   224         TBool contactIsBlocked = EFalse;
   224         
   225         RPointerArray<MXIMPIdentity> blockedList;
   225         // write pending to presence cache
   226         CleanupStack::PushL( TCleanupItem(
   226         TBuf<20> buf;
   227             TPresencePluginUtility::ResetAndDestroyIdentities,
   227         buf.Copy( KPendingRequestExtensionValue );
   228             &blockedList ) );
   228         
   229         iXdmUtils->SubscribeBlockListL( blockedList );
   229         iPresenceData->WriteStatusToCacheL( aMemberId.Identity(), 
   230         DP_SDA2( "CPresencePluginGroups::DoAddPresentityGroupMemberL - blockedList.Count = %d",
   230             MPresenceBuddyInfo2::ENotAvailable,
   231             blockedList.Count() );
   231             buf,
   232         
   232             KNullDesC() ); 
   233         for ( TInt i( 0 ); i < blockedList.Count() && !contactIsBlocked; i++ ) 
   233         
   234             {
   234         iConnObs.WatcherHandlerL()->DoPerformSubscribePresentityPresenceL( 
   235             if ( 0 == blockedList[i]->Identity().Compare( aMemberId.Identity() ) )
   235             aMemberId, iStatus );
   236                 {
   236         SetActive();
   237                 // contact found from blocked list
       
   238                 contactIsBlocked = ETrue;
       
   239                 }
       
   240             }
       
   241         CleanupStack::PopAndDestroy( &blockedList );
       
   242         
       
   243         if ( contactIsBlocked )
       
   244             {
       
   245             DP_SDA( "CPresencePluginGroups::DoAddPresentityGroupMemberL - contact is Blocked" );
       
   246             iOperation = EUnblockInAddPresentityGroupMember;
       
   247             iConnObs.InternalPresenceAuthorization().
       
   248                 DoPerformCancelPresenceBlockFromPresentityL(
       
   249                     aMemberId, iStatus  );
       
   250             SetActive();
       
   251             }
       
   252         else
       
   253             {
       
   254             DP_SDA( "CPresencePluginGroups::DoAddPresentityGroupMemberL - contact is not Blocked" );
       
   255             iOperation = EAddPresentityGroupMember;
       
   256             // write pending to presence cache
       
   257             TBuf<20> buf;
       
   258             buf.Copy( KPendingRequestExtensionValue );
       
   259             iPresenceData->WriteStatusToCacheL( aMemberId.Identity(), 
       
   260                 MPresenceBuddyInfo2::ENotAvailable,
       
   261                 buf,
       
   262                 KNullDesC() );
       
   263             iConnObs.WatcherHandlerL()->DoPerformSubscribePresentityPresenceL( 
       
   264                 aMemberId, iStatus );
       
   265             SetActive();
       
   266             }
   237         }
   267         }
   238     else if ( !aGroupId.Identity().Compare( KPresenceBlockedList ) )
   268     else if ( !aGroupId.Identity().Compare( KPresenceBlockedList ) )
   239         {
   269         {
   240         DP_SDA("CPresencePluginGroups::DoAddPresentityGroupMemberL - blockedlist");
   270         DP_SDA("CPresencePluginGroups::DoAddPresentityGroupMemberL - blockedlist");
   241         iOperation = EBlockPresentityGroupMember;
   271         iOperation = EBlockPresentityGroupMember;
   270     iXIMPId = aReqId;
   300     iXIMPId = aReqId;
   271     iOperation = ERemovePresentityGroupMember;
   301     iOperation = ERemovePresentityGroupMember;
   272     
   302     
   273     if( !aGroupId.Identity().Compare( KPresenceBuddyList ) )
   303     if( !aGroupId.Identity().Compare( KPresenceBuddyList ) )
   274         {
   304         {
   275         DP_SDA(" DoRemovePresentityGroupMemberL - buddylist");
   305         DP_SDA( "DoRemovePresentityGroupMemberL - buddylist" );
   276         iConnObs.WatcherHandlerL()->DoPerformUnsubscribePresentityPresenceL( 
   306         iConnObs.WatcherHandlerL()->DoPerformUnsubscribePresentityPresenceL( 
   277             aMemberId, iStatus );
   307             aMemberId, iStatus );
   278         SetActive();
   308         SetActive();
   279         }
   309         }
   280     else if ( !aGroupId.Identity().Compare( KPresenceBlockedList ) )
   310     else if ( !aGroupId.Identity().Compare( KPresenceBlockedList ) )
   281         {
   311         {
   282         DP_SDA(" DoRemovePresentityGroupMemberL - blockedlist");
   312         DP_SDA( "DoRemovePresentityGroupMemberL - blockedlist" );
   283         iOperation = EUnblockPresentityGroupMember;
   313         // Contact blocking is not cancelled when blocked contact is removed
   284         iConnObs.InternalPresenceAuthorization().
   314         // user can remove blocking from blocked list later
   285             DoPerformCancelPresenceBlockFromPresentityL( aMemberId, iStatus );
   315         DeletePersonCacheL();
   286         SetActive();
   316         CompleteXIMPReq( KErrNone );
   287         }
   317         }
   288     else
   318     else
   289         {
   319         {
   290         DP_SDA("DoRemovePresentityGroupMemberL - unknown, leave");
   320         DP_SDA("DoRemovePresentityGroupMemberL - unknown, leave");
   291         User::Leave( KErrNotSupported );
   321         User::Leave( KErrNotSupported );
   483                 }            
   513                 }            
   484             CompleteXIMPReq( aCompleteStatus );
   514             CompleteXIMPReq( aCompleteStatus );
   485             }
   515             }
   486             break;
   516             break;
   487             
   517             
       
   518         case EUnblockInAddPresentityGroupMember:
       
   519             {
       
   520             DP_SDA(" CallActualXdmOperationL EUnblockInAddPresentityGroupMember");
       
   521             iOperation = EAddPresentityGroupMember;
       
   522             MXIMPIdentity* newIdentity = iConnObs.ObjectFactory().NewIdentityLC();
       
   523             newIdentity->SetIdentityL( *iPresIdentity );
       
   524             
       
   525             TBuf<20> buf;
       
   526             buf.Copy( KPendingRequestExtensionValue );
       
   527             iPresenceData->WriteStatusToCacheL( *iPresIdentity,
       
   528                 MPresenceBuddyInfo2::ENotAvailable,
       
   529                 buf, KNullDesC() );
       
   530             
       
   531             iConnObs.WatcherHandlerL()->DoPerformSubscribePresentityPresenceL( 
       
   532                 *newIdentity, iStatus );
       
   533             CleanupStack::PopAndDestroy(); // >> newIdentity
       
   534             SetActive();
       
   535             }
       
   536             break;
       
   537             
   488         default:
   538         default:
   489             User::Leave( KErrNotSupported );
   539             User::Leave( KErrNotSupported );
   490             break;
   540             break;
   491         }   
   541         }
   492     DP_SDA("CPresencePluginGroups::CallActualXdmOperationL end");
   542     DP_SDA("CPresencePluginGroups::CallActualXdmOperationL end");
   493     }
   543     }
   494 
   544 
   495 // ---------------------------------------------------------------------------
   545 // ---------------------------------------------------------------------------
   496 // CPresencePluginGroups::RunError
   546 // CPresencePluginGroups::RunError