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