| Start/ | End/ | |||
| True | False | - | Line | Source |
| 1 | /* | |||
| 2 | * ============================================================================== | |||
| 3 | * Name : cimalertpropertyobserver.cpp | |||
| 4 | * Part of : conversations/instantmessagesalert | |||
| 5 | * Description : Publish & Subscribe property change observer implementation | |||
| 6 | * Version : %version: 1 % | |||
| 7 | * | |||
| 8 | * Copyright (c) 2009 Nokia. All rights reserved.. | |||
| 9 | * This material, including documentation and any related | |||
| 10 | * computer programs, is protected by copyright controlled by | |||
| 11 | * Nokia Corporation. All rights are reserved. Copying, | |||
| 12 | * including reproducing, storing, adapting or translating, any | |||
| 13 | * or all of this material requires the prior written consent of | |||
| 14 | * Nokia Corporation. This material also contains confidential | |||
| 15 | * information which may not be disclosed to others without the | |||
| 16 | * prior written consent of Nokia Corporation. | |||
| 17 | * ============================================================================== | |||
| 18 | */ | |||
| 19 | ||||
| 20 | // INCLUDE FILES | |||
| 21 | #include "cimalertpropertyobserver.h" | |||
| 22 | #include "mimalertpropertynotificationobserver.h" | |||
| 23 | ||||
| 24 | #include <bautils.h> | |||
| 25 | #include <barsc.h> | |||
| 26 | #include <e32property.h> | |||
| 27 | ||||
| 28 | ||||
| 29 | // ============================ MEMBER FUNCTIONS =============================== | |||
| 30 | ||||
| 31 | // ----------------------------------------------------------------------------- | |||
| 32 | // CIMAlertPropertyObserver::CIMAlertPropertyObserver | |||
| 33 | // C++ default constructor can NOT contain any code, that | |||
| 34 | // might leave. | |||
| 35 | // ----------------------------------------------------------------------------- | |||
| 36 | // | |||
| Top | ||||
| 34 | 34 | 37 | CIMAlertPropertyObserver::CIMAlertPropertyObserver( | |
| 38 | MCAPropertyNotificationObserver& aObserver ) | |||
| 39 | : CActive( CActive::EPriorityLow ), | |||
| 40 | iObserver( aObserver ) | |||
| 41 | { | |||
| 42 | CActiveScheduler::Add( this ); | |||
| 43 | } | |||
| 44 | ||||
| 45 | ||||
| 46 | // ----------------------------------------------------------------------------- | |||
| 47 | // CIMAlertPropertyObserver::NewL | |||
| 48 | // Two-phased constructor. | |||
| 49 | // ----------------------------------------------------------------------------- | |||
| 50 | // | |||
| Top | ||||
| 34 | 0 | 51 | CIMAlertPropertyObserver* CIMAlertPropertyObserver::NewL( | |
| 52 | MCAPropertyNotificationObserver& aObserver ) | |||
| 53 | { | |||
| 54 | CIMAlertPropertyObserver* self = new( ELeave ) CIMAlertPropertyObserver( aObserver ); | |||
| 34 | 55 | return self; | ||
| 56 | } | |||
| 57 | ||||
| 58 | ||||
| 59 | // Destructor | |||
| Top | ||||
| 34 | 34 | 60 | CIMAlertPropertyObserver::~CIMAlertPropertyObserver() | |
| 61 | { | |||
| 34 | 0 | - | 62 | if( IsActive() ) |
| 63 | { | |||
| 64 | Cancel(); | |||
| 65 | } | |||
| 66 | } | |||
| 67 | ||||
| 68 | ||||
| 69 | // ----------------------------------------------------------------------------- | |||
| 70 | // CIMAlertPropertyObserver::ObservePropertyChangeL | |||
| 71 | // (other items were commented in a header). | |||
| 72 | // ----------------------------------------------------------------------------- | |||
| 73 | // | |||
| Top | ||||
| 34 | 34 | 74 | void CIMAlertPropertyObserver::ObservePropertyChangeL( TUid aCategory, TUint aKey ) | |
| 75 | { | |||
| 0 | 34 | - | 76 | if( IsActive() ) |
| 77 | { | |||
| 0 | - | 78 | return; | |
| 79 | } | |||
| 80 | User::LeaveIfError( iProperty.Attach( aCategory, aKey ) ); | |||
| 81 | iKey = aKey; | |||
| 82 | iCategory = aCategory; | |||
| 83 | iProperty.Subscribe( iStatus ); | |||
| 84 | SetActive(); | |||
| 85 | } | |||
| 86 | ||||
| 87 | // ----------------------------------------------------------------------------- | |||
| 88 | // CIMAlertPropertyObserver::CancelObserve | |||
| 89 | // (other items were commented in a header). | |||
| 90 | // ----------------------------------------------------------------------------- | |||
| 91 | // | |||
| Top | ||||
| 0 | 0 | - | 92 | void CIMAlertPropertyObserver::CancelObserve() |
| 93 | { | |||
| 0 | 0 | - | 94 | if( IsActive() ) |
| 95 | { | |||
| 96 | Cancel(); | |||
| 97 | } | |||
| 98 | } | |||
| 99 | ||||
| 100 | // ----------------------------------------------------------------------------- | |||
| 101 | // CIMAlertPropertyObserver::RunL | |||
| 102 | // (other items were commented in a header). | |||
| 103 | // ----------------------------------------------------------------------------- | |||
| 104 | // | |||
| Top | ||||
| 0 | 0 | - | 105 | void CIMAlertPropertyObserver::RunL() |
| 106 | { | |||
| 107 | iProperty.Subscribe( iStatus ); | |||
| 108 | SetActive(); | |||
| 109 | iObserver.HandlePropertyNotificationEventL( iCategory, iKey ); | |||
| 110 | } | |||
| 111 | ||||
| 112 | // ----------------------------------------------------------------------------- | |||
| 113 | // CIMAlertPropertyObserver::DoCancel | |||
| 114 | // (other items were commented in a header). | |||
| 115 | // ----------------------------------------------------------------------------- | |||
| 116 | // | |||
| Top | ||||
| 34 | 34 | 117 | void CIMAlertPropertyObserver::DoCancel() | |
| 118 | { | |||
| 119 | iProperty.Cancel(); | |||
| 120 | } | |||
| 121 | ||||
| 122 | // ----------------------------------------------------------------------------- | |||
| 123 | // CIMAlertPropertyObserver::Category | |||
| 124 | // (other items were commented in a header). | |||
| 125 | // ----------------------------------------------------------------------------- | |||
| 126 | // | |||
| Top | ||||
| 0 | 0 | - | 127 | TUid CIMAlertPropertyObserver::Category() |
| 128 | { | |||
| 0 | - | 129 | return iCategory; | |
| 130 | } | |||
| 131 | ||||
| 132 | // ----------------------------------------------------------------------------- | |||
| 133 | // CIMAlertPropertyObserver::Key | |||
| 134 | // (other items were commented in a header). | |||
| 135 | // ----------------------------------------------------------------------------- | |||
| 136 | // | |||
| Top | ||||
| 0 | 0 | - | 137 | TUint CIMAlertPropertyObserver::Key() |
| 138 | { | |||
| 0 | - | 139 | return iKey; | |
| 140 | } | |||
| 141 | ||||
| 142 | // End of File | |||
| ***TER 42% (8/19) of SOURCE FILE cimalertpropertyobserver.cpp | ||||