ximpfw/presence/srcpresenceoperations/presentitygroups/operationhandlepresentitygroups.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:  implementation of COperationHandlePresentityGroups
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "operationhandlepresentitygroups.h"
       
    20 #include "grouplistsubscriptionitem.h"
       
    21 #include "presencedatacacheimp.h"
       
    22 #include "presentitygroupinfoimp.h"
       
    23 #include "ximphost.h"
       
    24 #include "ximpstatusimp.h"
       
    25 #include "ximppanics.h"
       
    26 #include "ximprestrictedobjectcollectionimp.h"
       
    27 #include "ximpobjectcollectionimp.h"
       
    28 #include "ximpobjecthelpers.h"
       
    29 #include "ximpidentityimp.h"
       
    30 #include "protocolpresencedatahostimp.h"
       
    31 
       
    32 #include "ximptrace.h"
       
    33 
       
    34 // ============================ MEMBER FUNCTIONS =============================
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // COperationHandlePresentityGroups::~COperationHandlePresentityGroups()
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 COperationHandlePresentityGroups::~COperationHandlePresentityGroups()
       
    41     {
       
    42     delete iGroupAddressList;
       
    43     }
       
    44 
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // COperationHandlePresentityGroups::COperationHandlePresentityGroups()
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C COperationHandlePresentityGroups::COperationHandlePresentityGroups(
       
    51         NPresenceOps::TPresenceOpTypes aMyType )
       
    52     {
       
    53     iMyType = aMyType;
       
    54     }
       
    55 
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // COperationHandlePresentityGroups::ConstructL()
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 void COperationHandlePresentityGroups::ConstructL( const TDesC8& /* aParamPck */ )
       
    62     {
       
    63     iGroupAddressList = new ( ELeave ) RPrGrpInfoImpArray;
       
    64     }
       
    65 
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // COperationHandlePresentityGroups::ProcessL()
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 void COperationHandlePresentityGroups::ProcessL()
       
    72     {
       
    73     TRACE(_L("COperationHandlePresentityGroups::ProcessL()") );
       
    74     CXIMPOperationBase::ProcessL();
       
    75 
       
    76     // recreate temporary lists
       
    77     CGroupListSubscriptionItem& groupListSubs = 
       
    78         iMyHost->PresenceDataAccess().PresenceDataCache().GroupListSubscriptionItemLC();
       
    79 
       
    80     // clean out temporary lists
       
    81     groupListSubs.Clean();
       
    82 
       
    83     switch ( iMyType )
       
    84         {
       
    85         case NPresenceOps::EPrHandlePresentityGroupList :
       
    86             {
       
    87             MXIMPBase* object = NULL;
       
    88             iObjCollection->GetByType( object, MXIMPObjectCollection::KInterfaceId );
       
    89             if( object )
       
    90                 {
       
    91                 CXIMPObjectCollectionImp* objectCollection = 
       
    92                         TXIMPGetImpClassOrPanic< CXIMPObjectCollectionImp >::From( *object );
       
    93                 CleanupStack::PushL( objectCollection );
       
    94                 TLinearOrder< CPresentityGroupInfoImp > order( CPresentityGroupInfoImp::GroupIdLinearOrder );
       
    95                 TXIMPObjectMover< MPresentityGroupInfo, CPresentityGroupInfoImp >::
       
    96                                             MoveFromCollectionToArrayL( *objectCollection, *iGroupAddressList, order );
       
    97                 CleanupStack::PopAndDestroy( objectCollection );        
       
    98                 }
       
    99             else
       
   100                 {
       
   101                 User::Leave( KErrArgument );
       
   102                 }
       
   103 
       
   104             // handling a list of groups
       
   105             groupListSubs.SetNewListL( iGroupAddressList );
       
   106             break;
       
   107             }
       
   108 
       
   109         case NPresenceOps::EPrHandlePresentityGroupCreated : // fall-through
       
   110         case NPresenceOps::EPrHandlePresentityGroupDisplayNameUpdated :
       
   111             {
       
   112             // handling a list of only created groups and/or
       
   113             // handling a list of groups which have display
       
   114             // name updated
       
   115             MXIMPBase* object = NULL;
       
   116             iObjCollection->GetByType( object, MPresentityGroupInfo::KInterfaceId );
       
   117             CPresentityGroupInfoImp* createdInfo = NULL;
       
   118             if( object )
       
   119                 {
       
   120                 createdInfo = 
       
   121                     TXIMPGetImpClassOrPanic< CPresentityGroupInfoImp >::From( *object );
       
   122                 }
       
   123             else
       
   124                 {
       
   125                 User::Leave( KErrArgument );
       
   126                 }
       
   127                         
       
   128             CleanupStack::PushL( createdInfo );
       
   129             iGroupAddressList->AppendL( createdInfo );
       
   130             CleanupStack::Pop( createdInfo );
       
   131             groupListSubs.SetCreatedListL( iGroupAddressList );
       
   132             break;
       
   133             }
       
   134 
       
   135         case NPresenceOps::EPrHandlePresentityGroupDeleted :
       
   136             {
       
   137             MXIMPBase* object = NULL;
       
   138             iObjCollection->GetByType( object, MXIMPIdentity::KInterfaceId );
       
   139             CXIMPIdentityImp* identity = NULL;
       
   140             if( object )
       
   141                 {
       
   142                 identity = TXIMPGetImpClassOrPanic< CXIMPIdentityImp >::From( *object );
       
   143                 CleanupStack::PushL( identity );
       
   144                 }
       
   145             else
       
   146                 {
       
   147                 User::Leave( KErrArgument );
       
   148                 }
       
   149             CPresentityGroupInfoImp* deletedInfo = CPresentityGroupInfoImp::NewLC( *identity, KNullDesC );            
       
   150             iGroupAddressList->AppendL( deletedInfo );
       
   151             CleanupStack::Pop( deletedInfo );
       
   152             CleanupStack::PopAndDestroy( identity );
       
   153             // handling a list of only deleted groups
       
   154             groupListSubs.SetDeletedListL( iGroupAddressList );
       
   155             break;
       
   156             }
       
   157 
       
   158         XIMP_DEFAULT_CASE_UNSUPPORTED( NXIMPPrivPanic::EInvalidOperationType );
       
   159         }
       
   160 
       
   161     iGroupAddressList = NULL;
       
   162     // ownership was transferred
       
   163 
       
   164     // synthesize the event to all contexts
       
   165     TRAP_IGNORE( groupListSubs.SynthesiseSubscriptionEventToAllCtxsL() );
       
   166  
       
   167     CleanupStack::PopAndDestroy(); // groupListSubs
       
   168 
       
   169     iMyHost->HandleAdaptationRequestCompleted( iReqId, KErrNone );
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 // COperationHandlePresentityGroups::RequestCompleted()
       
   174 // ---------------------------------------------------------------------------
       
   175 //
       
   176 void COperationHandlePresentityGroups::RequestCompletedL()
       
   177     {
       
   178     TRACE(_L("COperationHandlePresentityGroups::RequestCompletedL()" ) );
       
   179     CXIMPOperationBase::RequestCompletedL();    
       
   180     // no special handling for error situations
       
   181     }
       
   182 
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // COperationHandlePresentityGroups::Type()
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 TInt COperationHandlePresentityGroups::Type() const
       
   189     {
       
   190     return iMyType;
       
   191     }
       
   192 
       
   193 // End of file