clock2/clockui/uimodel/src/clkuimdlbase.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2008 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:  This is the source file for the CClkUiModelBase class.
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <e32def.h>
       
    20 
       
    21 // User includes
       
    22 #include "clkuimdlbase.h"
       
    23 #include "clkuilistenerbase.h"
       
    24 #include "clkuimdlpanic.h"
       
    25 #include "clkmdlobserver.h"
       
    26 // Constants
       
    27 
       
    28 // ---------------------------------------------------------
       
    29 // CClkUiModelBase::CClkUiModelBase
       
    30 // rest of the details are commented in the header
       
    31 // ---------------------------------------------------------
       
    32 //
       
    33 EXPORT_C CClkUiModelBase::CClkUiModelBase() : iNotifying( EFalse )
       
    34     {
       
    35     // No implementation yet.
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------
       
    39 // CClkUiModelBase::~CClkUiModelBase
       
    40 // rest of the details are commented in the header
       
    41 // ---------------------------------------------------------
       
    42 //
       
    43 EXPORT_C CClkUiModelBase::~CClkUiModelBase()
       
    44     {
       
    45     if( iListener )
       
    46         {
       
    47         delete iListener;
       
    48         iListener = NULL;
       
    49         }
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------
       
    53 // CClkUiModelBase::Start
       
    54 // rest of the details are commented in the header
       
    55 // ---------------------------------------------------------
       
    56 //
       
    57 EXPORT_C void CClkUiModelBase::Start()
       
    58     {
       
    59     iListener->Start();
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------
       
    63 // CClkUiModelBase::Stop
       
    64 // rest of the details are commented in the header
       
    65 // ---------------------------------------------------------
       
    66 //
       
    67 EXPORT_C void CClkUiModelBase::Stop()
       
    68     {
       
    69     if( iListener )
       
    70         {
       
    71         iListener->Cancel();
       
    72         }
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------
       
    76 // CClkUiModelBase::SetModelObserver
       
    77 // rest of the details are commented in the header
       
    78 // ---------------------------------------------------------
       
    79 //
       
    80 EXPORT_C void CClkUiModelBase::SetModelObserver( MClkModelObserver* aObserver )
       
    81     {
       
    82     // Save the observer.
       
    83     iObserver = aObserver;
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------
       
    87 // CClkUiModelBase::NotifyL
       
    88 // rest of the details are commented in the header
       
    89 // ---------------------------------------------------------
       
    90 //
       
    91 EXPORT_C void CClkUiModelBase::NotifyL( TInt aReason )
       
    92     {
       
    93     // If already notifying, we don't notify.
       
    94     if( !iNotifying && iObserver )
       
    95         {
       
    96         DoObserverNotifyL( aReason );
       
    97         }
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------
       
   101 // CClkUiModelBase::SetListenerActive
       
   102 // rest of the details are commented in the header
       
   103 // ---------------------------------------------------------
       
   104 //
       
   105 EXPORT_C void CClkUiModelBase::SetListenerActive( CClkUiMdlListenerBase* aListener )
       
   106     {
       
   107     // Save the listener first.
       
   108     iListener = aListener;
       
   109     
       
   110     if( iListener )
       
   111         {
       
   112         CActiveScheduler::Add( iListener );
       
   113         }
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------
       
   117 // CClkUiModelBase::DoObserverNotifyL
       
   118 // rest of the details are commented in the header
       
   119 // ---------------------------------------------------------
       
   120 //
       
   121 void CClkUiModelBase::DoObserverNotifyL( TInt aReason )
       
   122     {
       
   123     __ASSERT_DEBUG( iObserver, Panic( EClkUiMdlObserver ) );
       
   124     
       
   125     iNotifying = ETrue;
       
   126     
       
   127     iObserver->HandleUpdateL( aReason );
       
   128     
       
   129     iNotifying = EFalse;
       
   130     }
       
   131 
       
   132 // End of file