ximpfw/presence/srcpresenceoperations/operationsetsubscriptiondata.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:  Set subscription data
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "operationsetsubscriptiondata.h"
       
    20 #include "ximpsubscriptionitem.h"
       
    21 #include "ximphost.h"
       
    22 #include "ownpresencesubscriptionitem.h"
       
    23 #include "grouplistsubscriptionitem.h"
       
    24 #include "groupcontentsubscriptionitem.h"
       
    25 #include "presentitypresencesubscriptionitem.h"
       
    26 #include "presentitygroupmemberspresencesubscriptionitem.h"
       
    27 #include "watcherlistsubscriptionitem.h"
       
    28 #include "grantrequestlistsubscriptionitem.h"
       
    29 #include "blocklistsubscriptionitem.h"
       
    30 #include "ximpobjecthelpers.h"
       
    31 #include "ximppanics.h"
       
    32 #include "ximpidentityimp.h"
       
    33 #include "ximppsccontextimp.h"
       
    34 #include "ximprestrictedobjectcollectionimp.h"
       
    35 #include "ximpstatusimp.h"
       
    36 #include "ximpdatasubscriptionstateimp.h"
       
    37 #include "presencedatacacheimp.h"
       
    38 #include "protocolpresencedatahostimp.h"
       
    39 
       
    40 #include "ximptrace.h"
       
    41 
       
    42 // ============================ MEMBER FUNCTIONS =============================
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // COperationSetSubscriptionData::COperationSetSubscriptionData()
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 EXPORT_C COperationSetSubscriptionData::COperationSetSubscriptionData(
       
    49     NPresenceOps::TPresenceOpTypes aType )
       
    50     :iType( aType )
       
    51     {
       
    52     }
       
    53 
       
    54 
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // COperationSetSubscriptionData::~COperationSetSubscriptionData()
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 COperationSetSubscriptionData::~COperationSetSubscriptionData()
       
    61     {
       
    62     delete iStatus;
       
    63     delete iSubscriptionState;
       
    64     delete iIdentity;
       
    65     }
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // COperationSetSubscriptionData::ConstructL()
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 void COperationSetSubscriptionData::ConstructL( const TDesC8& /*aParamPck*/ )
       
    72     {
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // COperationSynthesiseSubscriptionEvent::ProcessL()
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 void COperationSetSubscriptionData::ProcessL()
       
    80     {
       
    81     TRACE(_L("COperationSetSubscriptionData::ProcessL()" ) );
       
    82     CXIMPOperationBase::ProcessL();
       
    83 
       
    84     MXIMPBase* object = NULL;
       
    85     iObjCollection->GetByType( object, MXIMPIdentity::KInterfaceId );
       
    86     if( object )
       
    87         {
       
    88         iIdentity = TXIMPGetImpClassOrPanic< CXIMPIdentityImp >::From( *object );        
       
    89         }
       
    90 
       
    91     iObjCollection->GetByType( object, MXIMPDataSubscriptionState::KInterfaceId );
       
    92     if( object )
       
    93         {
       
    94         iSubscriptionState = TXIMPGetImpClassOrPanic< CXIMPDataSubscriptionStateImp >::From( *object );        
       
    95         }
       
    96     else
       
    97         {
       
    98         User::Leave( KErrArgument );
       
    99         }
       
   100 
       
   101     iObjCollection->GetByType( object, MXIMPDataSubscriptionState::KInterfaceId );
       
   102     if( object )
       
   103         {
       
   104         iSubscriptionState = TXIMPGetImpClassOrPanic< CXIMPDataSubscriptionStateImp >::From( *object );        
       
   105         }
       
   106     else
       
   107         {
       
   108         User::Leave( KErrArgument );
       
   109         }
       
   110 
       
   111     iObjCollection->GetByType( object, MXIMPStatus::KInterfaceId );
       
   112     if( object )
       
   113         {
       
   114         iStatus = TXIMPGetImpClassOrPanic< CXIMPStatusImp >::From( *object );        
       
   115         }
       
   116     
       
   117     MXIMPSubscriptionItem* subscriptionItem = NULL;
       
   118     switch( iType )
       
   119         {
       
   120         case NPresenceOps::EPrSetOwnPresenceDataSubscriptionState:
       
   121             {
       
   122             subscriptionItem = &iMyHost->PresenceDataAccess().PresenceDataCache().OwnPresenceSubscriptionItemLC();
       
   123             break;
       
   124             }
       
   125         case NPresenceOps::EPrSetPresenceBlockDataSubscriptionState:
       
   126             {
       
   127             subscriptionItem = &iMyHost->PresenceDataAccess().PresenceDataCache().BlockListSubscriptionItemLC();
       
   128             break;
       
   129             }
       
   130         case NPresenceOps::EPrSetPresenceGrantRequestDataSubscriptionState:
       
   131             {
       
   132             subscriptionItem = &iMyHost->PresenceDataAccess().PresenceDataCache().GrantRequestListSubscriptionItemLC();
       
   133             break;
       
   134             }
       
   135         case NPresenceOps::EPrSetPresenceWatcherListDataSubscriptionState:
       
   136             {
       
   137             subscriptionItem = &iMyHost->PresenceDataAccess().PresenceDataCache().WatcherListSubscriptionItemLC();
       
   138             break;
       
   139             }
       
   140         case NPresenceOps::EPrSetPresentityGroupListDataSubscriptionState:
       
   141             {
       
   142             subscriptionItem = &iMyHost->PresenceDataAccess().PresenceDataCache().GroupListSubscriptionItemLC();
       
   143             break;
       
   144             }
       
   145         case NPresenceOps::EPrSetPresentityGroupContentDataSubscriptionState:
       
   146             {
       
   147             if( !iIdentity )
       
   148                 {
       
   149                 User::Leave( KErrArgument );
       
   150                 }
       
   151             subscriptionItem = &iMyHost->PresenceDataAccess().PresenceDataCache().GroupContentSubscriptionItemLC( *iIdentity );
       
   152             break;
       
   153             }
       
   154         case NPresenceOps::EPrSetPresentityPresenceDataSubscriptionState:
       
   155             {
       
   156             if( !iIdentity )
       
   157                 {
       
   158                 User::Leave( KErrArgument );
       
   159                 }
       
   160             subscriptionItem = &iMyHost->PresenceDataAccess().PresenceDataCache().PresentityPresenceSubscriptionItemLC( *iIdentity );
       
   161             break;
       
   162             }
       
   163 
       
   164         XIMP_DEFAULT_CASE_UNSUPPORTED( NXIMPPrivPanic::EInvalidSubscriptionType );
       
   165         }
       
   166 
       
   167     subscriptionItem->SetDataSubscriptionStateL( *iSubscriptionState );
       
   168     iSubscriptionState = NULL;
       
   169 
       
   170     iMyHost->HandleAdaptationRequestCompleted( iReqId, KErrNone );
       
   171     }
       
   172 
       
   173 // ---------------------------------------------------------------------------
       
   174 // COperationSetSubscriptionData::RequestCompleted()
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 void COperationSetSubscriptionData::RequestCompletedL()
       
   178     {
       
   179     TRACE(_L("COperationSetSubscriptionData::RequestCompletedL()" ) );
       
   180     CXIMPOperationBase::RequestCompletedL();
       
   181     }
       
   182 
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // COperationSetSubscriptionData::Type()
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 TInt
       
   189     COperationSetSubscriptionData::Type() const
       
   190     {
       
   191     return iType;
       
   192     }
       
   193 
       
   194 
       
   195 
       
   196 // End of file