ximpfw/presence/srcpresenceoperations/presentitygroups/operationhandlepresentitygroupmemberadded.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 "operationhandlepresentitygroupmemberadded.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 "protocolpresencedatahostimp.h"
       
    29 
       
    30 #include "ximptrace.h"
       
    31 // ============================ MEMBER FUNCTIONS =============================
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // COperationHandlePresentityGroupMemberAdded::~COperationHandlePresentityGroupMemberAdded()
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 COperationHandlePresentityGroupMemberAdded::~COperationHandlePresentityGroupMemberAdded()
       
    38     {
       
    39     delete iMemberInfo;
       
    40     delete iGroupId;
       
    41     }
       
    42 
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // COperationHandlePresentityGroupMemberAdded::COperationHandlePresentityGroupMemberAdded()
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 EXPORT_C COperationHandlePresentityGroupMemberAdded::COperationHandlePresentityGroupMemberAdded()
       
    49     {
       
    50     }
       
    51 
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // COperationHandlePresentityGroupMemberAdded::ConstructL()
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 void COperationHandlePresentityGroupMemberAdded::ConstructL( const TDesC8& /*aParamPck*/ )
       
    58     {
       
    59     }
       
    60 
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // COperationHandlePresentityGroupMemberAdded::ProcessL()
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 void COperationHandlePresentityGroupMemberAdded::ProcessL()
       
    67     {
       
    68     TRACE(_L("COperationHandlePresentityGroupMemberAdded::ProcessL()") );
       
    69     CXIMPOperationBase::ProcessL();
       
    70 
       
    71     MXIMPBase* object = NULL;
       
    72     iObjCollection->GetByType( object, MXIMPIdentity::KInterfaceId );
       
    73     if( object )
       
    74         {
       
    75         iGroupId = TXIMPGetImpClassOrPanic< CXIMPIdentityImp >::From( *object );        
       
    76         }
       
    77     else
       
    78         {
       
    79         User::Leave( KErrArgument );
       
    80         }
       
    81         
       
    82     object = NULL;
       
    83     iObjCollection->GetByType( object, MPresentityGroupMemberInfo::KInterfaceId );
       
    84     if( object )
       
    85         {
       
    86         iMemberInfo = TXIMPGetImpClassOrPanic< CPresentityGroupMemberInfoImp >::From( *object );
       
    87         }
       
    88     else
       
    89         {
       
    90         User::Leave( KErrArgument );
       
    91         }
       
    92 
       
    93     // Check if the item exits, only full subscriptions are allowed to
       
    94     // create new ones.
       
    95     if ( iMyHost->PresenceDataAccess().PresenceDataCache().GroupContentSubscriptionItemExists( *iGroupId ) )
       
    96         {
       
    97         CGroupContentSubscriptionItem& subItem =
       
    98             iMyHost->PresenceDataAccess().PresenceDataCache().GroupContentSubscriptionItemLC( *iGroupId );
       
    99 
       
   100         // clean out temporary lists
       
   101         subItem.Clean();
       
   102 
       
   103         if ( !subItem.GroupMemberExistsL( *iMemberInfo ) )
       
   104             {
       
   105             // New member
       
   106             RPrGrpMemInfoImpArray* added = new ( ELeave ) RPrGrpMemInfoImpArray;
       
   107             CleanupStack::PushL( added );
       
   108             added->AppendL( iMemberInfo );
       
   109             iMemberInfo = NULL; // ownership was transferred
       
   110 
       
   111             subItem.SetAddedListL( added );
       
   112             CleanupStack::Pop( added ); // ownership was transferred
       
   113 
       
   114             // synthesize the event to all contexts
       
   115             TRAP_IGNORE( subItem.SynthesiseSubscriptionEventToAllCtxsL() );
       
   116             }
       
   117         else if ( subItem.IsGroupMemberUpdatedL( *iMemberInfo ) )
       
   118             {
       
   119             // Existing member updated (actually this implementation might be redundant
       
   120             // because of the implementation of subcription item. Refactor if needed.
       
   121             RPrGrpMemInfoImpArray* updated = new ( ELeave ) RPrGrpMemInfoImpArray;
       
   122             CleanupStack::PushL( updated );
       
   123             updated->AppendL( iMemberInfo );
       
   124             iMemberInfo = NULL; // ownership was transferred
       
   125 
       
   126             subItem.SetAddedListL( updated );
       
   127             CleanupStack::Pop( updated ); // ownership was transferred
       
   128 
       
   129             // synthesize the event to all contexts
       
   130             TRAP_IGNORE( subItem.SynthesiseSubscriptionEventToAllCtxsL() );
       
   131             }
       
   132             
       
   133         CleanupStack::PopAndDestroy(); // subItem
       
   134         }
       
   135 
       
   136     iMyHost->HandleAdaptationRequestCompleted( iReqId, KErrNone );
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // COperationHandlePresentityGroupMemberAdded::RequestCompleted()
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 void COperationHandlePresentityGroupMemberAdded::RequestCompletedL()
       
   144     {
       
   145     TRACE(_L("COperationHandlePresentityGroupMemberAdded::RequestCompletedL()" ) );
       
   146     CXIMPOperationBase::RequestCompletedL();
       
   147 
       
   148     // no special handling for error situations
       
   149     }
       
   150 
       
   151 
       
   152 // ---------------------------------------------------------------------------
       
   153 // COperationHandlePresentityGroupMemberAdded::Type()
       
   154 // ---------------------------------------------------------------------------
       
   155 //
       
   156 TInt
       
   157     COperationHandlePresentityGroupMemberAdded::Type() const
       
   158     {
       
   159     return NPresenceOps::EPrHandlePresentityGroupMemberAdded;
       
   160     }
       
   161 
       
   162 
       
   163 // End of file