ximpfw/presence/srcpresenceoperations/presentitygroups/operationaddpresentitygroupmember.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:  Add Presentity Group Member operation
       
    15  *
       
    16 */
       
    17 
       
    18 #include <s32mem.h>
       
    19 #include <ximpprotocolconnection.h>
       
    20 #include <protocolpresentitygroups.h>
       
    21 #include <protocolpresencefeatures.h>
       
    22 
       
    23 #include "operationaddpresentitygroupmember.h"
       
    24 #include "presentitygroupmemberinfoimp.h"
       
    25 #include "ximpidentityimp.h"
       
    26 #include "ximprbufhelpers.h"
       
    27 #include "ximprestrictedobjectcollectionimp.h"
       
    28 #include "protocolpresentitygroupsdatahostimp.h"
       
    29 #include "ximphost.h"
       
    30 #include "ximpstatusimp.h"
       
    31 #include "ximprequestcompleteeventimp.h"
       
    32 #include "ximpobjecthelpers.h"
       
    33 #include "protocolpresencedatahostimp.h"
       
    34 
       
    35 #include "ximptrace.h"
       
    36 
       
    37 // ======== MEMBER FUNCTIONS ========
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // COperationAddPresentityGroupMember::COperationAddPresentityGroupMember()
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 EXPORT_C COperationAddPresentityGroupMember::COperationAddPresentityGroupMember()
       
    44     {
       
    45     }
       
    46 
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // COperationAddPresentityGroupMember::ConstructL
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 void COperationAddPresentityGroupMember::ConstructL( const TDesC8& aParamPck )
       
    53     {
       
    54     RDesReadStream rs;
       
    55     rs.Open( aParamPck ); // CSI: 65 # Does not return a value.
       
    56     CleanupClosePushL( rs );
       
    57 
       
    58     // group id
       
    59     iGroupId = CXIMPIdentityImp::NewLC();
       
    60     CleanupStack::Pop( iGroupId );
       
    61     iGroupId->InternalizeL( rs );
       
    62 
       
    63     // member id
       
    64     CXIMPIdentityImp* memberId = CXIMPIdentityImp::NewLC();
       
    65     memberId->InternalizeL( rs );
       
    66 
       
    67     // member display name
       
    68     RBuf16 dispName;
       
    69     CleanupClosePushL( dispName );
       
    70     XIMPRBuf16Helper::InternalizeL( dispName, rs );
       
    71 
       
    72     iMemberInfo = CPresentityGroupMemberInfoImp::NewLC( *memberId, dispName );
       
    73     CleanupStack::Pop( iMemberInfo );
       
    74     CleanupStack::PopAndDestroy( 3 ); // dispName, memberId, rs
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // COperationAddPresentityGroupMember::~COperationAddPresentityGroupMember()
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 COperationAddPresentityGroupMember::~COperationAddPresentityGroupMember()
       
    82     {
       
    83     delete iGroupId;
       
    84     delete iMemberInfo;
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // COperationAddPresentityGroupMember::ProcessL()
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 void COperationAddPresentityGroupMember::ProcessL()
       
    92     {
       
    93     TRACE(_L("COperationAddPresentityGroupMember::ProcessL()" ) );
       
    94     CXIMPOperationBase::ProcessL();
       
    95 
       
    96     MProtocolPresentityGroups& connection = iMyHost->GetConnection().ProtocolPresenceFeatures().PresentityGroups();
       
    97 
       
    98     connection.DoAddPresentityGroupMemberL( *iGroupId,
       
    99                                             iMemberInfo->GroupMemberId(),
       
   100                                             iMemberInfo->GroupMemberDisplayName(),
       
   101                                             iReqId );
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // COperationAddPresentityGroupMember::RequestCompletedL()
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void COperationAddPresentityGroupMember::RequestCompletedL()
       
   109     {
       
   110     TRACE(_L("COperationAddPresentityGroupMember::RequestCompletedL()" ) );
       
   111     CXIMPOperationBase::RequestCompletedL();
       
   112 
       
   113     MXIMPBase* object = NULL;
       
   114     iObjCollection->GetByType( object, MPresentityGroupMemberInfo::KInterfaceId );
       
   115     if( object )
       
   116         {
       
   117         CPresentityGroupMemberInfoImp* memberInfo = 
       
   118         TXIMPGetImpClassOrPanic< CPresentityGroupMemberInfoImp >::From( *object );            
       
   119         
       
   120         delete iMemberInfo;
       
   121         iMemberInfo = memberInfo;
       
   122         }
       
   123 
       
   124     if ( iStatusObj->ResultCode() == KErrNone )
       
   125         {
       
   126         CXIMPIdentityImp* groupId = 
       
   127                 TXIMPObjectCloner< CXIMPIdentityImp >::CloneL( *iGroupId );
       
   128         CleanupStack::PushL( groupId );
       
   129         CPresentityGroupMemberInfoImp* memberInfo = 
       
   130                 TXIMPObjectCloner< CPresentityGroupMemberInfoImp >::CloneL( *iMemberInfo );
       
   131         CleanupStack::PushL( memberInfo );
       
   132         iMyHost->PresenceDataAccess().GroupsDataAccess().HandlePresentityGroupMemberAddedL( groupId, memberInfo );
       
   133         CleanupStack::Pop( 2, groupId );
       
   134         }
       
   135 
       
   136     // Set information for request complete event.
       
   137     iReqCompleteEvent->AppendParamL( iGroupId );
       
   138     iGroupId = NULL;
       
   139     iReqCompleteEvent->AppendParamL( iMemberInfo );
       
   140     iMemberInfo = NULL;
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // COperationAddPresentityGroupMember::Type()
       
   145 // ---------------------------------------------------------------------------
       
   146 //
       
   147 TInt COperationAddPresentityGroupMember::Type() const
       
   148     {
       
   149     return NPresenceOps::EPrAddPresentityGroupMember;
       
   150     }
       
   151 
       
   152 // End of file