ximpfw/presence/srcpresenceoperations/presentitygroups/operationunsubscribegrouplist.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:  Presentity group list unsubscription operation
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include <ximpprotocolconnection.h>
       
    20 #include <protocolpresentitygroups.h>
       
    21 #include <protocolpresencefeatures.h>
       
    22 
       
    23 #include "operationunsubscribegrouplist.h"
       
    24 #include "presencedatacacheimp.h"
       
    25 #include "ximppanics.h"
       
    26 #include "operationsynthesisesubscriptionevent.h"
       
    27 #include "ximphost.h"
       
    28 #include "ximppsccontextimp.h"
       
    29 #include "ximpstatusimp.h"
       
    30 #include "protocolpresencedatahostimp.h"
       
    31 
       
    32 #include "ximptrace.h"
       
    33 // ============================ MEMBER FUNCTIONS =============================
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // COperationUnsubscribeGroupList::COperationUnsubscribeGroupList()
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 EXPORT_C COperationUnsubscribeGroupList::COperationUnsubscribeGroupList()
       
    40     {
       
    41     }
       
    42 
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // COperationUnsubscribeGroupList::~COperationUnsubscribeGroupList()
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 COperationUnsubscribeGroupList::~COperationUnsubscribeGroupList()
       
    49     {
       
    50     if( iGroupList )
       
    51         {
       
    52         iGroupList->Close();
       
    53         }
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // COperationUnsubscribeGroupList::ConstructL()
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 void COperationUnsubscribeGroupList::ConstructL( const TDesC8& /*aParamPck*/ )
       
    61     {
       
    62     }
       
    63 
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // COperationUnsubscribeGroupList::ProcessL()
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 void COperationUnsubscribeGroupList::ProcessL()
       
    70     {
       
    71     TRACE(_L("COperationUnsubscribeGroupList::ProcessL()" ) );
       
    72     CXIMPOperationBase::ProcessL();
       
    73 
       
    74     CGroupListSubscriptionItem& groupList =
       
    75                             iMyHost->PresenceDataAccess().PresenceDataCache().GroupListSubscriptionItemLC();
       
    76     CleanupStack::Pop(); // ownPresence
       
    77     iGroupList = &groupList;
       
    78 
       
    79     iSubscriptionStatus = iGroupList->SubscriptionStatus( iContext );
       
    80 
       
    81     MProtocolPresentityGroups& presentityGroups = iMyHost->GetConnection().ProtocolPresenceFeatures().PresentityGroups();
       
    82 
       
    83     switch( iSubscriptionStatus )
       
    84         {
       
    85         case CGroupListSubscriptionItem::ESubscribedForCtxOnly:
       
    86             {
       
    87             // Do subscribe
       
    88             presentityGroups.DoUnsubscribePresentityGroupListL( iReqId );
       
    89             break;
       
    90             }
       
    91         case CGroupListSubscriptionItem::ESubscribedForCtxAndOthers:
       
    92         case CGroupListSubscriptionItem::ENotSubscribedAtAll:
       
    93         case CGroupListSubscriptionItem::ESubscribedForOtherCtxOnly:
       
    94             {
       
    95             // Everything is ok. We are not handling updates through this one.
       
    96             // Already subscribed -> complete request.
       
    97             iMyHost->FakeCompleteRequest( iReqId, KErrNone );
       
    98             break;
       
    99             }
       
   100 
       
   101         XIMP_DEFAULT_CASE_UNSUPPORTED( NXIMPPrivPanic::EInvalidSubscriptionStatus );
       
   102         }
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // COperationUnsubscribeGroupList::RequestCompleted()
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 void COperationUnsubscribeGroupList::RequestCompletedL()
       
   110     {
       
   111     TRACE(_L("COperationUnsubscribeGroupList::RequestCompletedL()" ) );
       
   112     CXIMPOperationBase::RequestCompletedL();
       
   113 
       
   114     if( iStatusObj->ResultCode() == KErrNone )
       
   115         {
       
   116         switch( iSubscriptionStatus )
       
   117             {
       
   118             case CGroupListSubscriptionItem::ESubscribedForCtxOnly:
       
   119             case CGroupListSubscriptionItem::ESubscribedForCtxAndOthers:
       
   120                 {
       
   121                 iGroupList->RemoveSubscriber( iContext );
       
   122                 break;
       
   123                 }
       
   124             case CGroupListSubscriptionItem::ENotSubscribedAtAll:
       
   125             case CGroupListSubscriptionItem::ESubscribedForOtherCtxOnly:
       
   126                 {
       
   127                 break;
       
   128                 }
       
   129                 
       
   130             XIMP_DEFAULT_CASE_UNSUPPORTED( NXIMPPrivPanic::EInvalidSubscriptionStatus );                
       
   131             }
       
   132         SynthesiseEventL();
       
   133         }
       
   134     }
       
   135 
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // COperationUnsubscribeGroupList::Type()
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 TInt
       
   142     COperationUnsubscribeGroupList::Type() const
       
   143     {
       
   144     return NPresenceOps::EPrUnsubscribeGroupList;
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // COperationUnsubscribeGroupList::SynthesiseEventL()
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 void COperationUnsubscribeGroupList::SynthesiseEventL()
       
   152     {
       
   153     COperationSynthesiseSubscriptionEvent* synthOp =
       
   154             new ( ELeave ) COperationSynthesiseSubscriptionEvent(
       
   155                              COperationSynthesiseSubscriptionEvent::EPresentityGroupList, ETrue );
       
   156     CleanupStack::PushL( synthOp );
       
   157     synthOp->BaseConstructL( TXIMPRequestId(), iContext );
       
   158     iMyHost->AddNewOperationL( *synthOp );
       
   159     CleanupStack::Pop( synthOp );
       
   160     }
       
   161 
       
   162 
       
   163 // End of file