| Start/ | End/ | |||
| True | False | - | Line | Source |
| 1 | /* | |||
| 2 | * ============================================================================== | |||
| 3 | * Name : cimalertnotifierimpl.cpp | |||
| 4 | * Part of : conversations/instantmessagesalert | |||
| 5 | * Description : Publish and subscribe implementation | |||
| 6 | * Version : %version: 2 % | |||
| 7 | * | |||
| 8 | * Copyright © 2009 Nokia. All rights reserved.. | |||
| 9 | * This material, including documentation and any related | |||
| 10 | * computer programs, is protected by copyright controlled by | |||
| 11 | * Nokia. All rights are reserved. Copying, including | |||
| 12 | * reproducing, storing, adapting or translating, any | |||
| 13 | * or all of this material requires the prior written consent of | |||
| 14 | * Nokia. This material also contains confidential | |||
| 15 | * information which may not be disclosed to others without the | |||
| 16 | * prior written consent of Nokia. | |||
| 17 | * ============================================================================== | |||
| 18 | */ | |||
| 19 | ||||
| 20 | ||||
| 21 | // INCLUDE FILES | |||
| 22 | #include "cimalertnotifierimpl.h" | |||
| 23 | #include "mimalertnotifierkeyobserver.h" | |||
| 24 | #include "cimalertpropertyobserver.h" | |||
| 25 | #include <e32property.h> | |||
| 26 | ||||
| 27 | // ============================ MEMBER FUNCTIONS =============================== | |||
| 28 | ||||
| 29 | // ----------------------------------------------------------------------------- | |||
| 30 | // CIMAlertNotifierImpl::CIMAlertNotifierImpl | |||
| 31 | // C++ default constructor can NOT contain any code, that | |||
| 32 | // might leave. | |||
| 33 | // ----------------------------------------------------------------------------- | |||
| 34 | // | |||
| Top | ||||
| 34 | 34 | 35 | CIMAlertNotifierImpl::CIMAlertNotifierImpl( MIMAlertNotifierKeyObserver* aObserver ) | |
| 36 | :iObserver( aObserver ) | |||
| 37 | { | |||
| 38 | } | |||
| 39 | ||||
| 40 | // ----------------------------------------------------------------------------- | |||
| 41 | // CIMAlertNotifierImpl::NewL | |||
| 42 | // Two-phased constructor. | |||
| 43 | // ----------------------------------------------------------------------------- | |||
| 44 | // | |||
| Top | ||||
| 34 | 0 | 45 | CIMAlertNotifierImpl* CIMAlertNotifierImpl::NewL( MIMAlertNotifierKeyObserver* aObserver ) | |
| 46 | { | |||
| 47 | CIMAlertNotifierImpl* self = new( ELeave ) CIMAlertNotifierImpl( aObserver ); | |||
| 48 | return self; | |||
| 49 | } | |||
| 50 | ||||
| 51 | ||||
| 52 | // Destructor | |||
| Top | ||||
| 34 | 34 | 53 | CIMAlertNotifierImpl::~CIMAlertNotifierImpl() | |
| 54 | { | |||
| 55 | delete iPropWatcher; | |||
| 56 | delete iCallState; | |||
| 57 | } | |||
| 58 | ||||
| 59 | // ----------------------------------------------------------------------------- | |||
| 60 | // CIMAlertNotifierImpl::SetInt | |||
| 61 | // (other items were commented in a header). | |||
| 62 | // ----------------------------------------------------------------------------- | |||
| 63 | // | |||
| Top | ||||
| 4 | 0 | 64 | TInt CIMAlertNotifierImpl::SetInt( TNotifyKey aKey, TInt aValue ) | |
| 65 | { | |||
| 66 | TInt err = KErrNone; | |||
| 67 | switch ( aKey ) | |||
| 68 | { | |||
| 69 | case EMSGToneQuitKey: | |||
| 70 | err = RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsMessageToneQuit, aValue ); | |||
| 71 | break; | |||
| 72 | case ECallState: | |||
| 73 | { | |||
| 74 | err = RProperty::Set( KPSUidCtsyCallInformation, KCTsyCallState, aValue ); | |||
| 75 | break; | |||
| 76 | } | |||
| 77 | default: | |||
| 78 | { | |||
| 79 | return KErrNotFound; | |||
| 80 | } | |||
| 81 | } | |||
| 82 | return err; | |||
| 83 | } | |||
| 84 | ||||
| 85 | // ----------------------------------------------------------------------------- | |||
| 86 | // CIMAlertNotifierImpl::GetInt | |||
| 87 | // (other items were commented in a header). | |||
| 88 | // ----------------------------------------------------------------------------- | |||
| 89 | // | |||
| Top | ||||
| 0 | 0 | - | 90 | TInt CIMAlertNotifierImpl::GetInt( TNotifyKey aKey, TInt& aValue ) |
| 91 | { | |||
| 92 | TInt err = KErrNone; | |||
| 93 | switch ( aKey ) | |||
| 94 | { | |||
| 95 | case EMSGToneQuitKey: | |||
| 96 | { | |||
| 97 | err = RProperty::Get( KPSUidCoreApplicationUIs, KCoreAppUIsMessageToneQuit, aValue ); | |||
| 98 | break; | |||
| 99 | } | |||
| 100 | case ECallState: | |||
| 101 | { | |||
| 102 | err = RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, aValue ); | |||
| 103 | break; | |||
| 104 | } | |||
| 105 | default: | |||
| 106 | { | |||
| 107 | err = KErrNotFound; | |||
| 108 | break; | |||
| 109 | } | |||
| 110 | } | |||
| 111 | return err; | |||
| 112 | } | |||
| 113 | ||||
| 114 | // ----------------------------------------------------------------------------- | |||
| 115 | // CIMAlertNotifierImpl::ListenKeyChanges | |||
| 116 | // (other items were commented in a header). | |||
| 117 | // ----------------------------------------------------------------------------- | |||
| 118 | // | |||
| Top | ||||
| 68 | 0 | 119 | TInt CIMAlertNotifierImpl::ListenKeyChanges( TNotifyKey aKey ) | |
| 120 | { | |||
| 121 | TInt err = KErrNone; | |||
| 122 | switch ( aKey ) | |||
| 123 | { | |||
| 124 | case EMSGToneQuitKey: | |||
| 125 | { | |||
| 126 | delete iPropWatcher; | |||
| 127 | iPropWatcher = NULL; | |||
| 128 | TRAP( err, iPropWatcher = CIMAlertPropertyObserver::NewL( *this ) ); | |||
| 129 | if( !err ) | |||
| 130 | { | |||
| 131 | TRAP( err, iPropWatcher->ObservePropertyChangeL( | |||
| 132 | KPSUidCoreApplicationUIs, KCoreAppUIsMessageToneQuit ) ); | |||
| 133 | } | |||
| 134 | break; | |||
| 135 | } | |||
| 136 | case ECallState: | |||
| 137 | { | |||
| 138 | delete iCallState; | |||
| 139 | iCallState = NULL; | |||
| 140 | TRAP( err, iCallState = CIMAlertPropertyObserver::NewL( *this ) ); | |||
| 141 | if( !err ) | |||
| 142 | { | |||
| 143 | TRAP( err, iCallState->ObservePropertyChangeL( | |||
| 144 | KPSUidCtsyCallInformation, KCTsyCallState ) ); | |||
| 145 | } | |||
| 146 | break; | |||
| 147 | } | |||
| 148 | default: | |||
| 149 | { | |||
| 150 | err = KErrNotFound; | |||
| 151 | break; | |||
| 152 | } | |||
| 153 | } | |||
| 154 | return err; | |||
| 155 | } | |||
| 156 | ||||
| 157 | // ----------------------------------------------------------------------------- | |||
| 158 | // CIMAlertNotifierImpl::HandlePropertyNotificationEventL | |||
| 159 | // (other items were commented in a header). | |||
| 160 | // ----------------------------------------------------------------------------- | |||
| 161 | // | |||
| Top | ||||
| 0 | 0 | - | 162 | void CIMAlertNotifierImpl::HandlePropertyNotificationEventL( TUid aCategory , TUint aKey ) |
| 163 | { | |||
| 164 | TInt value( 0 ); | |||
| 165 | TUpdatedKey key; | |||
| 166 | // KPSUidCoreApplicationUIs status changed | |||
| 167 | if ( aCategory == KPSUidCoreApplicationUIs && aKey == KCoreAppUIsMessageToneQuit ) | |||
| 168 | { | |||
| 169 | User::LeaveIfError( | |||
| 170 | RProperty::Get( KPSUidCoreApplicationUIs, aKey, value ) ); | |||
| 171 | key.iUid = KPSUidCoreApplicationUIs; | |||
| 172 | key.iKey = aKey; | |||
| 173 | key.iValue = value; | |||
| 174 | } | |||
| 175 | // call status changed | |||
| 176 | if ( aCategory == KPSUidCtsyCallInformation && aKey == KCTsyCallState ) | |||
| 177 | { | |||
| 178 | User::LeaveIfError( | |||
| 179 | RProperty::Get( KPSUidCtsyCallInformation, aKey, value ) ); | |||
| 180 | key.iUid = KPSUidCtsyCallInformation; | |||
| 181 | key.iKey = aKey; | |||
| 182 | key.iValue = value; | |||
| 183 | } | |||
| 184 | iObserver->HandleKeyChange( key ); | |||
| 185 | } | |||
| 186 | ||||
| 187 | // End of File | |||
| ***TER 71% (5/7) of SOURCE FILE cimalertnotifierimpl.cpp | ||||