cbs/cbsui/UiSrc/CCbsUiTopicListMonitor.cpp
branchRCL_3
changeset 20 987c9837762f
parent 0 ff3b6d0fd310
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
       
     1 /*
       
     2 * Copyright (c) 2002 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:  
       
    15 *       Implementaion of CCbsUiTopicListMonitor.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDES
       
    22 #include "MCbs.h"
       
    23 #include "CCbsUiTopicListMonitor.h"
       
    24 #include "MCbsUiTopicMonitorObserver.h"
       
    25 #include "CbsUiPanic.h"
       
    26 #include "CbsUiConstants.h"
       
    27 
       
    28 
       
    29 
       
    30 // CONSTANTS
       
    31 const TInt KNumberOfObservers = 3;
       
    32 
       
    33 
       
    34 
       
    35 
       
    36 // ================= MEMBER FUNCTIONS =======================
       
    37 
       
    38 // C++ default constructor can NOT contain any code, that
       
    39 // might leave.
       
    40 //
       
    41 CCbsUiTopicListMonitor::CCbsUiTopicListMonitor( MCbs& aServer )
       
    42     : CActive(EPriorityStandard), iContinue(ETrue), iServer(aServer)
       
    43     {
       
    44     }
       
    45 
       
    46 // Symbian OS default constructor can leave
       
    47 void CCbsUiTopicListMonitor::ConstructL( )
       
    48     {    
       
    49     CActiveScheduler::Add(this);
       
    50     IssueRequest();
       
    51 
       
    52     iObservers = new (ELeave) TCbsUiMonitorObservers(KNumberOfObservers);
       
    53     }
       
    54 
       
    55 
       
    56 // Two-phased constructor.
       
    57 CCbsUiTopicListMonitor* CCbsUiTopicListMonitor::NewL( MCbs& aServer )
       
    58     {
       
    59     CCbsUiTopicListMonitor* self = 
       
    60         new (ELeave) CCbsUiTopicListMonitor(aServer);
       
    61     
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL();
       
    64     CleanupStack::Pop();
       
    65 
       
    66     return self;
       
    67     }
       
    68 
       
    69     
       
    70 // Destructor
       
    71 CCbsUiTopicListMonitor::~CCbsUiTopicListMonitor()
       
    72     {
       
    73     delete iObservers;
       
    74     Cancel();
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------
       
    78 // CCbsUiTopicListMonitor::IssueRequest()
       
    79 // 
       
    80 // 
       
    81 // ---------------------------------------------------------
       
    82 void CCbsUiTopicListMonitor::IssueRequest()
       
    83     {
       
    84     if ( iContinue )
       
    85         {
       
    86         SetActive();
       
    87 
       
    88         iServer.NotifyOnTopicListEvent( 
       
    89             iStatus, ECbsTopicAllEvents, iEvent, iTopicNumber );
       
    90         }
       
    91     }
       
    92 
       
    93 
       
    94 // ---------------------------------------------------------
       
    95 // CCbsUiTopicListMonitor::RunL
       
    96 // 
       
    97 // 
       
    98 // ---------------------------------------------------------
       
    99 void CCbsUiTopicListMonitor::RunL()  
       
   100 
       
   101     {
       
   102     if ( iObservers->Count() > 0 )
       
   103         {
       
   104         for ( TInt i(0); i < iObservers->Count(); i++ )
       
   105             {
       
   106             iObservers->At(i)->TopicListChangedL(iEvent, iTopicNumber);
       
   107             }
       
   108         }
       
   109 
       
   110     __ASSERT_DEBUG( 
       
   111         (iEvent & ECbsTopicAllEvents), CbsUiPanic(EErrInvalidEvent) );
       
   112 
       
   113     if ( iContinue )
       
   114         {
       
   115         IssueRequest();
       
   116         }
       
   117     }
       
   118 
       
   119 
       
   120 // ---------------------------------------------------------
       
   121 // CCbsUiTopicListMonitor::DoCancel
       
   122 // 
       
   123 // 
       
   124 // ---------------------------------------------------------
       
   125 void CCbsUiTopicListMonitor::DoCancel()
       
   126     {
       
   127     iContinue = EFalse;
       
   128 
       
   129     iServer.NotifyOnTopicListEventCancel();
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------
       
   133 // CCbsUiTopicListMonitor::AddObserverL
       
   134 // 
       
   135 // 
       
   136 // ---------------------------------------------------------
       
   137 void CCbsUiTopicListMonitor::AddObserverL(
       
   138     MCbsUiTopicMonitorObserver* aObserver )
       
   139     {
       
   140     __ASSERT_DEBUG( iObservers, CbsUiPanic(EErrNullPointer) );
       
   141     __ASSERT_DEBUG( aObserver, CbsUiPanic(EErrNullPointer) );
       
   142 
       
   143     iObservers->AppendL(aObserver);
       
   144     }
       
   145 
       
   146 
       
   147 //  End of File