ximpfw/presence/srcpresenceoperations/presenceauthorization/operationhandlepresenceblocking.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:  Handle presence blocking operations
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "operationhandlepresenceblocking.h"
       
    20 #include "ximpobjecthelpers.h"
       
    21 #include "blocklistsubscriptionitem.h"
       
    22 #include "presencedatacacheimp.h"
       
    23 #include "presenceblockinfoimp.h"
       
    24 #include "ximpidentityimp.h"
       
    25 #include "ximphost.h"
       
    26 #include "ximpstatusimp.h"
       
    27 #include "ximppanics.h"
       
    28 #include "ximprestrictedobjectcollectionimp.h"
       
    29 #include "ximpobjectcollectionimp.h"
       
    30 #include "protocolpresencedatahostimp.h"
       
    31 
       
    32 #include "ximptrace.h"
       
    33 // ============================ MEMBER FUNCTIONS =============================
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // COperationHandlePresenceBlocking::~COperationHandlePresenceBlocking()
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 COperationHandlePresenceBlocking::~COperationHandlePresenceBlocking()
       
    40     {
       
    41     delete iBlockList;
       
    42     delete iBlocked;
       
    43     delete iCanceledBlockId;
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // COperationHandlePresenceBlocking::COperationHandlePresenceBlocking()
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C COperationHandlePresenceBlocking::COperationHandlePresenceBlocking(
       
    51         TInt aMyType )
       
    52     {
       
    53     iMyType = aMyType;
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // COperationHandlePresenceBlocking::ConstructL()
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 void COperationHandlePresenceBlocking::ConstructL( const TDesC8& /*aParamPck*/ )
       
    61     {
       
    62     iBlockList = new( ELeave ) RPrBlockInfoImpArray;
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // COperationHandlePresenceBlocking::ProcessL()
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 void COperationHandlePresenceBlocking::ProcessL()
       
    70     {
       
    71     TRACE(_L("COperationHandlePresenceBlocking::ProcessL()") );
       
    72     CXIMPOperationBase::ProcessL();
       
    73 
       
    74     CBlockListSubscriptionItem& subItem =
       
    75         iMyHost->PresenceDataAccess().PresenceDataCache().BlockListSubscriptionItemLC();
       
    76     // clean out temporary lists
       
    77     subItem.Clean();
       
    78 
       
    79     switch ( iMyType )
       
    80         {
       
    81         case NPresenceOps::EPrHandlePresenceBlockList:
       
    82             {
       
    83             MXIMPBase* object = NULL;
       
    84             iObjCollection->GetByType( object, MXIMPObjectCollection::KInterfaceId );
       
    85             if( object )
       
    86                 {
       
    87                 CXIMPObjectCollectionImp* objectCollection = 
       
    88                         TXIMPGetImpClassOrPanic< CXIMPObjectCollectionImp >::From( *object );
       
    89                 CleanupStack::PushL( objectCollection );
       
    90                 TLinearOrder< CPresenceBlockInfoImp > order( CPresenceBlockInfoImp::IdLinearOrder );
       
    91                 TXIMPObjectMover< MPresenceBlockInfo, CPresenceBlockInfoImp >::
       
    92                                             MoveFromCollectionToArrayL( *objectCollection, *iBlockList, order );
       
    93                 CleanupStack::PopAndDestroy( objectCollection );        
       
    94                 }
       
    95             else
       
    96                 {
       
    97                 User::Leave( KErrArgument );
       
    98                 }
       
    99 
       
   100             subItem.SetNewListL( iBlockList );
       
   101             iBlockList = NULL;
       
   102             break;
       
   103             }
       
   104 
       
   105         case NPresenceOps::EPrHandlePresenceBlocked:
       
   106             {
       
   107             MXIMPBase* object = NULL;
       
   108             iObjCollection->GetByType( object, MPresenceBlockInfo::KInterfaceId );
       
   109             if( object )
       
   110                 {
       
   111                 iBlocked = TXIMPGetImpClassOrPanic< CPresenceBlockInfoImp >::From( *object );
       
   112                 }
       
   113             else
       
   114                 {
       
   115                 User::Leave( KErrArgument );
       
   116                 }            
       
   117             subItem.SetBlockedL( iBlocked );
       
   118             iBlocked = NULL; // ownership was transferred
       
   119             break;
       
   120             }
       
   121 
       
   122         case NPresenceOps::EPrHandlePresenceBlockCanceled:
       
   123             {
       
   124             MXIMPBase* object = NULL;
       
   125             iObjCollection->GetByType( object, MXIMPIdentity::KInterfaceId );
       
   126             if( object )
       
   127                 {
       
   128                 iCanceledBlockId = TXIMPGetImpClassOrPanic< CXIMPIdentityImp >::From( *object );
       
   129                 }
       
   130             else
       
   131                 {
       
   132                 User::Leave( KErrArgument );
       
   133                 }            
       
   134             subItem.SetCanceledBlockIdL( iCanceledBlockId );
       
   135             iCanceledBlockId = NULL; // ownership was transferred
       
   136             break;
       
   137             }
       
   138 
       
   139         XIMP_DEFAULT_CASE_UNSUPPORTED( NXIMPPrivPanic::EInvalidOperationType );
       
   140         }
       
   141 
       
   142     // synthesize the event to all contexts
       
   143     TRAPD( err, subItem.SynthesiseSubscriptionEventToAllCtxsL() );
       
   144 
       
   145     CleanupStack::PopAndDestroy(); // subItem
       
   146 
       
   147     err = KErrNone;
       
   148     iMyHost->HandleAdaptationRequestCompleted( iReqId, err );
       
   149     }
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // COperationHandlePresenceBlocking::RequestCompleted()
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 void COperationHandlePresenceBlocking::RequestCompletedL()
       
   156     {
       
   157     TRACE(_L("COperationHandlePresenceBlocking::RequestCompletedL()" ) );
       
   158     CXIMPOperationBase::RequestCompletedL();
       
   159 
       
   160     // no special handling for error situations
       
   161     }
       
   162 
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 // COperationHandlePresenceBlocking::Type()
       
   166 // ---------------------------------------------------------------------------
       
   167 //
       
   168 TInt COperationHandlePresenceBlocking::Type() const
       
   169     {
       
   170     return iMyType;
       
   171     }
       
   172 
       
   173 // End of file