ximpfw/presence/srcpresenceoperations/presencepublishing/operationsubscribewatcherlist.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:  Presence watcher list subscription operator
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include <ximpprotocolconnection.h>
       
    20 #include <protocolpresencepublishing.h>
       
    21 #include <protocolpresencefeatures.h>
       
    22 
       
    23 #include "operationsubscribewatcherlist.h"
       
    24 #include "presencedatacacheimp.h"
       
    25 #include "ximppanics.h"
       
    26 #include "operationsynthesisesubscriptionevent.h"
       
    27 #include "ximphost.h"
       
    28 #include "ximpstatusimp.h"
       
    29 #include "ximppsccontextimp.h"
       
    30 #include "protocolpresencedatahostimp.h"
       
    31 
       
    32 #include "ximptrace.h"
       
    33 
       
    34 // ============================ MEMBER FUNCTIONS =============================
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // COperationSubscribeWatcherList::COperationSubscribeWatcherList()
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 EXPORT_C COperationSubscribeWatcherList::COperationSubscribeWatcherList()
       
    41     {
       
    42     }
       
    43 
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // COperationSubscribeWatcherList::~COperationSubscribeWatcherList()
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 COperationSubscribeWatcherList::~COperationSubscribeWatcherList()
       
    50     {
       
    51     if( iWatcherList )
       
    52         {
       
    53         iWatcherList->Close();
       
    54         }
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // COperationSubscribeWatcherList::ConstructL()
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 void COperationSubscribeWatcherList::ConstructL( const TDesC8& /*aParamPck*/ )
       
    62     {
       
    63     }
       
    64 
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // COperationSubscribeWatcherList::ProcessL()
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 void COperationSubscribeWatcherList::ProcessL()
       
    71     {
       
    72     TRACE(_L("COperationSubscribeWatcherList::ProcessL()" ) );
       
    73     CXIMPOperationBase::ProcessL();
       
    74 
       
    75     CWatcherListSubscriptionItem& watcherList =
       
    76                             iMyHost->PresenceDataAccess().PresenceDataCache().WatcherListSubscriptionItemLC();
       
    77     CleanupStack::Pop(); // watcherList
       
    78     iWatcherList = &watcherList;
       
    79 
       
    80     iSubscriptionStatus = iWatcherList->SubscriptionStatus( iContext );
       
    81     MProtocolPresencePublishing& publishing = iMyHost->GetConnection().ProtocolPresenceFeatures().PresencePublishing();
       
    82 
       
    83     switch( iSubscriptionStatus )
       
    84         {
       
    85         case CWatcherListSubscriptionItem::ENotSubscribedAtAll:
       
    86             {
       
    87             publishing.DoSubscribePresenceWatcherListL( iReqId );
       
    88             break;
       
    89             }
       
    90             
       
    91         case CWatcherListSubscriptionItem::ESubscribedForOtherCtxOnly:
       
    92         case CWatcherListSubscriptionItem::ESubscribedForCtxOnly:
       
    93         case CWatcherListSubscriptionItem::ESubscribedForCtxAndOthers:
       
    94             {
       
    95             iMyHost->FakeCompleteRequest( iReqId, KErrNone );
       
    96             break;
       
    97             }
       
    98 
       
    99         XIMP_DEFAULT_CASE_UNSUPPORTED( NXIMPPrivPanic::EInvalidSubscriptionStatus );
       
   100         }
       
   101     }
       
   102 
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // COperationSubscribeWatcherList::RequestCompleted()
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void COperationSubscribeWatcherList::RequestCompletedL()
       
   109     {
       
   110     TRACE(_L("COperationSubscribeWatcherList::RequestCompletedL()" ) );
       
   111     CXIMPOperationBase::RequestCompletedL();
       
   112 
       
   113     if( iStatusObj->ResultCode() == KErrNone )
       
   114         {
       
   115         switch( iSubscriptionStatus )
       
   116             {
       
   117             case CWatcherListSubscriptionItem::ENotSubscribedAtAll:
       
   118             case CWatcherListSubscriptionItem::ESubscribedForOtherCtxOnly:
       
   119                 {
       
   120                 iWatcherList->AddSubscriberL( iContext );
       
   121                 break;
       
   122                 }
       
   123                 
       
   124             case CWatcherListSubscriptionItem::ESubscribedForCtxOnly:
       
   125             case CWatcherListSubscriptionItem::ESubscribedForCtxAndOthers:
       
   126                 {
       
   127                 break;
       
   128                 }
       
   129                 
       
   130             XIMP_DEFAULT_CASE_UNSUPPORTED( NXIMPPrivPanic::EInvalidSubscriptionStatus );
       
   131             }
       
   132 
       
   133         SynthesiseEventL();
       
   134         }
       
   135     }
       
   136 
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // COperationSubscribeWatcherList::Type()
       
   140 // ---------------------------------------------------------------------------
       
   141 //
       
   142 TInt
       
   143     COperationSubscribeWatcherList::Type() const
       
   144     {
       
   145     return NPresenceOps::EPrSubscribePresenceWatcherList;
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // COperationSubscribeWatcherList::SynthesiseEventL()
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 void COperationSubscribeWatcherList::SynthesiseEventL()
       
   153     {
       
   154     TBool force =
       
   155     ( iSubscriptionStatus == CWatcherListSubscriptionItem::ESubscribedForCtxOnly ||
       
   156       iSubscriptionStatus == CWatcherListSubscriptionItem::ESubscribedForCtxAndOthers ) ? ETrue : EFalse;
       
   157 
       
   158     COperationSynthesiseSubscriptionEvent* synthOp =
       
   159             new ( ELeave ) COperationSynthesiseSubscriptionEvent(
       
   160                              COperationSynthesiseSubscriptionEvent::EPresenceWatcherList,
       
   161                              force );
       
   162     CleanupStack::PushL( synthOp );
       
   163     synthOp->BaseConstructL( TXIMPRequestId(), iContext );
       
   164     iMyHost->AddNewOperationL( *synthOp );
       
   165     CleanupStack::Pop( synthOp );
       
   166     }
       
   167 
       
   168 
       
   169 
       
   170 // End of file