ximpfw/presence/srcpresenceoperations/presencewatching/operationunsubscribepresentitygroupmemberspresence.cpp
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Presentity group members presence unsubscription operation
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include <ximpprotocolconnection.h>
       
    20 #include <protocolpresencewatching.h>
       
    21 #include <protocolpresencefeatures.h>
       
    22 
       
    23 #include "operationunsubscribepresentitygroupmemberspresence.h"
       
    24 #include "ximpobjecthelpers.h"
       
    25 #include "ximpidentityimp.h"
       
    26 #include "presencedatacacheimp.h"
       
    27 #include "presenceinfofilterimp.h"
       
    28 #include "operationsynthesisesubscriptionevent.h"
       
    29 #include "ximphost.h"
       
    30 #include "ximpstatusimp.h"
       
    31 #include "ximppsccontextimp.h"
       
    32 #include "ximppanics.h"
       
    33 #include "protocolpresencedatahostimp.h"
       
    34 
       
    35 #include "ximptrace.h"
       
    36 // ============================ MEMBER FUNCTIONS =============================
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // COperationUnsubscribePresentityGroupMembersPresence::COperationUnsubscribePresentityGroupMembersPresence()
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 EXPORT_C COperationUnsubscribePresentityGroupMembersPresence::COperationUnsubscribePresentityGroupMembersPresence()
       
    43     {
       
    44     }
       
    45 
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // COperationUnsubscribePresentityGroupMembersPresence::~COperationUnsubscribePresentityGroupMembersPresence()
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 COperationUnsubscribePresentityGroupMembersPresence::~COperationUnsubscribePresentityGroupMembersPresence()
       
    52     {
       
    53     delete iGroupId;
       
    54     if( iSubItem )
       
    55         {
       
    56         iSubItem->Close();
       
    57         }    
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // COperationUnsubscribePresentityGroupMembersPresence::ConstructL()
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 void COperationUnsubscribePresentityGroupMembersPresence::ConstructL( const TDesC8& aParamPck )
       
    65     {
       
    66     iGroupId = CXIMPIdentityImp::NewLC();
       
    67     CleanupStack::Pop( iGroupId );
       
    68     TXIMPObjectPacker< CXIMPIdentityImp >::UnPackL( *iGroupId, aParamPck );
       
    69     }
       
    70 
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // COperationUnsubscribePresentityGroupMembersPresence::ProcessL()
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 void COperationUnsubscribePresentityGroupMembersPresence::ProcessL()
       
    77     {
       
    78     TRACE(_L("COperationUnsubscribePresentityGroupMembersPresence::ProcessL()" ) );
       
    79     CXIMPOperationBase::ProcessL();
       
    80     
       
    81     CPresentityGroupMembersPresenceSubscriptionItem& subItem =
       
    82                 iMyHost->PresenceDataAccess().PresenceDataCache().PresentityGroupMembersPresenceSubscriptionItemLC( *iGroupId );
       
    83     CleanupStack::Pop(); // subItem
       
    84     iSubItem = &subItem;
       
    85 
       
    86     iSubscriptionStatus = iSubItem->SubscriptionStatus( iContext );
       
    87 
       
    88     MProtocolPresenceWatching& watching = iMyHost->GetConnection().ProtocolPresenceFeatures().PresenceWatching();
       
    89 
       
    90     switch( iSubscriptionStatus )
       
    91         {
       
    92         case CPresentityGroupMembersPresenceSubscriptionItem::ESubscribedForCtxOnly:
       
    93             {
       
    94             watching.DoUnsubscribePresentityGroupMembersPresenceL( *iGroupId, iReqId );
       
    95             iSubItem->RemoveSubscriber( iContext );
       
    96             break;
       
    97             }
       
    98             
       
    99         case CPresentityGroupMembersPresenceSubscriptionItem::ESubscribedForCtxAndOthers:
       
   100             {
       
   101             CPresenceInfoFilterImp* pifWithoutCtx =
       
   102                 iSubItem->CollectSubscriptionPifWithoutCtxL( iContext );
       
   103             CleanupStack::PushL( pifWithoutCtx );
       
   104 
       
   105             if ( iSubItem->SubscriptionPif().Contains( *pifWithoutCtx ) )
       
   106                 {
       
   107                 watching.DoUpdatePresentityGroupMembersPresenceSubscriptionPifL( *iGroupId, *pifWithoutCtx, iReqId );
       
   108                 }
       
   109             else
       
   110                 {
       
   111                 iMyHost->FakeCompleteRequest( iReqId, KErrNone );
       
   112                 }
       
   113 
       
   114             CleanupStack::PopAndDestroy( pifWithoutCtx );
       
   115             break;
       
   116             }
       
   117             
       
   118         case CPresentityGroupMembersPresenceSubscriptionItem::ENotSubscribedAtAll:
       
   119         case CPresentityGroupMembersPresenceSubscriptionItem::ESubscribedForOtherCtxOnly:
       
   120             {
       
   121             iMyHost->FakeCompleteRequest( iReqId, KErrNone );
       
   122             break;
       
   123             }
       
   124             
       
   125         XIMP_DEFAULT_CASE_UNSUPPORTED( NXIMPPrivPanic::EInvalidSubscriptionStatus );
       
   126         }    
       
   127     }
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // COperationUnsubscribePresentityGroupMembersPresence::RequestCompleted()
       
   131 // ---------------------------------------------------------------------------
       
   132 //
       
   133 void COperationUnsubscribePresentityGroupMembersPresence::RequestCompletedL()
       
   134     {
       
   135     TRACE(_L("COperationUnsubscribePresentityGroupMembersPresence::RequestCompletedL()" ) );
       
   136     CXIMPOperationBase::RequestCompletedL();
       
   137 
       
   138     if( iStatusObj->ResultCode() == KErrNone )
       
   139         {
       
   140         iContext->SetPresenceInfoFilterL( MXIMPPscContext::EPresentityGroupMemberPresenceFilter,
       
   141                 NULL, iGroupId );
       
   142 
       
   143         switch( iSubscriptionStatus )
       
   144             {
       
   145             case CPresentityGroupMembersPresenceSubscriptionItem::ESubscribedForCtxOnly:
       
   146             case CPresentityGroupMembersPresenceSubscriptionItem::ESubscribedForCtxAndOthers:
       
   147                 {
       
   148                 iSubItem->RemoveSubscriber( iContext );
       
   149                 break;
       
   150                 }
       
   151                 
       
   152             case CPresentityGroupMembersPresenceSubscriptionItem::ENotSubscribedAtAll:
       
   153             case CPresentityGroupMembersPresenceSubscriptionItem::ESubscribedForOtherCtxOnly:
       
   154                 {
       
   155                 break;
       
   156                 }
       
   157                 
       
   158             XIMP_DEFAULT_CASE_UNSUPPORTED( NXIMPPrivPanic::EInvalidSubscriptionStatus );
       
   159             }
       
   160 
       
   161         SynthesiseEventL();
       
   162         }
       
   163     }
       
   164 
       
   165 
       
   166 // ---------------------------------------------------------------------------
       
   167 // COperationUnsubscribePresentityGroupMembersPresence::Type()
       
   168 // ---------------------------------------------------------------------------
       
   169 //
       
   170 TInt
       
   171     COperationUnsubscribePresentityGroupMembersPresence::Type() const
       
   172     {
       
   173     return NPresenceOps::EPrUnsubscribePresentityGroupMembersPresence;
       
   174     }
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // COperationUnsubscribePresentityGroupMembersPresence::SynthesiseEventL()
       
   178 // ---------------------------------------------------------------------------
       
   179 //
       
   180 void COperationUnsubscribePresentityGroupMembersPresence::SynthesiseEventL()
       
   181     {
       
   182     COperationSynthesiseSubscriptionEvent* synthOp =
       
   183             new ( ELeave ) COperationSynthesiseSubscriptionEvent(
       
   184                              COperationSynthesiseSubscriptionEvent::EPresentityGroupMembersPresence, EFalse );
       
   185     CleanupStack::PushL( synthOp );
       
   186     synthOp->BaseConstructL( TXIMPRequestId(), iContext );
       
   187     synthOp->ConstructL( *iGroupId );
       
   188     iMyHost->AddNewOperationL( *synthOp );
       
   189     CleanupStack::Pop( synthOp );
       
   190     }
       
   191 
       
   192 
       
   193 // End of file