ximpfw/presence/srcpresenceoperations/presentitygroups/operationhandlepresentitygroupcontent.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 presentity group content operations
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "operationhandlepresentitygroupcontent.h"
       
    20 #include "ximpobjecthelpers.h"
       
    21 #include "groupcontentsubscriptionitem.h"
       
    22 #include "presencedatacacheimp.h"
       
    23 #include "presentitygroupmemberinfoimp.h"
       
    24 #include "ximpidentityimp.h"
       
    25 #include "ximphost.h"
       
    26 #include "ximpstatusimp.h"
       
    27 #include "ximprestrictedobjectcollectionimp.h"
       
    28 #include "ximpobjectcollectionimp.h"
       
    29 #include "protocolpresencedatahostimp.h"
       
    30 
       
    31 #include "ximptrace.h"
       
    32 // ============================ MEMBER FUNCTIONS =============================
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // COperationHandlePresentityGroupContent::~COperationHandlePresentityGroupContent()
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 COperationHandlePresentityGroupContent::~COperationHandlePresentityGroupContent()
       
    39     {
       
    40     delete iGroupMemberList;
       
    41     delete iGroupId;
       
    42     }
       
    43 
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // COperationHandlePresentityGroupContent::COperationHandlePresentityGroupContent()
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 EXPORT_C COperationHandlePresentityGroupContent::COperationHandlePresentityGroupContent()
       
    50     {
       
    51     }
       
    52 
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // COperationHandlePresentityGroupContent::ConstructL()
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 void COperationHandlePresentityGroupContent::ConstructL( const TDesC8& /*aParamPck*/ )
       
    59     {
       
    60     iGroupMemberList = new ( ELeave ) RPrGrpMemInfoImpArray;
       
    61     }
       
    62 
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // COperationHandlePresentityGroupContent::ProcessL()
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 void COperationHandlePresentityGroupContent::ProcessL()
       
    69     {
       
    70     TRACE(_L("COperationHandlePresentityGroupContent::ProcessL()") );
       
    71     CXIMPOperationBase::ProcessL();
       
    72 
       
    73     MXIMPBase* object = NULL;
       
    74     iObjCollection->GetByType( object, MXIMPIdentity::KInterfaceId );
       
    75     if( object )
       
    76         {
       
    77         iGroupId = TXIMPGetImpClassOrPanic< CXIMPIdentityImp >::From( *object );        
       
    78         }
       
    79     else
       
    80         {
       
    81         User::Leave( KErrArgument );
       
    82         }
       
    83         
       
    84     object = NULL;
       
    85     iObjCollection->GetByType( object, MXIMPObjectCollection::KInterfaceId );
       
    86     if( object )
       
    87         {
       
    88         CXIMPObjectCollectionImp* objectCollection = 
       
    89                 TXIMPGetImpClassOrPanic< CXIMPObjectCollectionImp >::From( *object );
       
    90         CleanupStack::PushL( objectCollection );
       
    91         TLinearOrder< CPresentityGroupMemberInfoImp > order( CPresentityGroupMemberInfoImp::GroupIdLinearOrder );
       
    92         TXIMPObjectMover< MPresentityGroupMemberInfo, CPresentityGroupMemberInfoImp >::
       
    93                                     MoveFromCollectionToArrayL( *objectCollection, *iGroupMemberList, order );
       
    94         CleanupStack::PopAndDestroy( objectCollection );        
       
    95         }
       
    96     else
       
    97         {
       
    98         User::Leave( KErrArgument );
       
    99         }
       
   100 
       
   101     // recreate temporary lists
       
   102     CGroupContentSubscriptionItem& subItem =
       
   103         iMyHost->PresenceDataAccess().PresenceDataCache().GroupContentSubscriptionItemLC( *iGroupId );
       
   104 
       
   105     // clean out temporary lists
       
   106     subItem.Clean();
       
   107     
       
   108     subItem.SetNewListL( iGroupMemberList );
       
   109     iGroupMemberList = NULL; // ownership was transferred
       
   110     
       
   111     subItem.UpdateSubscriptionStateL( CXIMPSubscriptionItemBase::ECompleteDataReceived );
       
   112 
       
   113     // synthesize the event to all contexts
       
   114     TRAPD( err, subItem.SynthesiseSubscriptionEventToAllCtxsL() );
       
   115 
       
   116     CleanupStack::PopAndDestroy(); // subItem
       
   117 
       
   118     err = KErrNone;
       
   119     iMyHost->HandleAdaptationRequestCompleted( iReqId, err );
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // COperationHandlePresentityGroupContent::RequestCompleted()
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 void COperationHandlePresentityGroupContent::RequestCompletedL()
       
   127     {
       
   128     TRACE(_L("COperationHandlePresentityGroupContent::RequestCompletedL()" ) );
       
   129     CXIMPOperationBase::RequestCompletedL();
       
   130     // no special handling for error situations
       
   131     }
       
   132     
       
   133     
       
   134 // ---------------------------------------------------------------------------
       
   135 // COperationHandlePresentityGroupContent::Type()
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 TInt
       
   139     COperationHandlePresentityGroupContent::Type() const
       
   140     {
       
   141     return NPresenceOps::EPrHandlePresentityGroupContent;
       
   142     }    
       
   143 
       
   144 // End of file