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