|
1 /* |
|
2 * Copyright (c) 2006 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: Implementation of the CTelDMCallStateListener class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CTelDMCallStateListener.h" |
|
22 #include "MTelDMCallStateObserver.h" |
|
23 #include "MTelDMAccessory.h" |
|
24 |
|
25 #include <ctsydomainpskeys.h> |
|
26 |
|
27 // MODULE DATA STRUCTURES |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CTelDMCallStateListener::NewL |
|
33 // |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CTelDMCallStateListener* CTelDMCallStateListener::NewL() |
|
37 { |
|
38 |
|
39 CTelDMCallStateListener* self = |
|
40 new ( ELeave ) CTelDMCallStateListener; |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop( self ); |
|
44 return self; |
|
45 } |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CTelDMCallStateListener::CTelDMCallStateListener |
|
50 // |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CTelDMCallStateListener::CTelDMCallStateListener(): |
|
54 CActive( CActive::EPriorityStandard ) |
|
55 { |
|
56 CActiveScheduler::Add( this ); |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CTelDMCallStateListener::~CTelDMCallStateListener |
|
61 // |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CTelDMCallStateListener::~CTelDMCallStateListener() |
|
65 { |
|
66 Cancel(); |
|
67 iProperty.Close(); |
|
68 iObserverArray.Reset(); |
|
69 iObserverArray.Close(); |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CTelDMCallStateListener::ConstructL |
|
74 // |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CTelDMCallStateListener::ConstructL() |
|
78 { |
|
79 /// Attach to key. Start listening call state changes. |
|
80 iProperty.Attach( KPSUidCtsyCallInformation, KCTsyCallState ); |
|
81 IssueRequest(); |
|
82 |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CTelDMCallStateListener::HandleChange |
|
87 // |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CTelDMCallStateListener::HandleChange() |
|
91 { |
|
92 TInt err( KErrNone ); |
|
93 iCallState = KErrNone; |
|
94 err = RProperty::Get( KPSUidCtsyCallInformation, |
|
95 KCTsyCallState, |
|
96 iCallState ); |
|
97 if ( err == KErrNone ) |
|
98 { |
|
99 for ( TInt i = 0; i < iObserverArray.Count(); i++ ) |
|
100 { |
|
101 TRAP_IGNORE( iObserverArray[ i ]->CallStateChangedL(iCallState) ); |
|
102 } |
|
103 } |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CTelDMCallStateListener::RunL |
|
108 // Cannot leave, no RunError implementation |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CTelDMCallStateListener::RunL() |
|
112 { |
|
113 if ( iStatus.Int() == KErrNone ) |
|
114 { |
|
115 HandleChange(); |
|
116 } |
|
117 IssueRequest(); |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CTelDMCallStateListener::DoCancel |
|
122 // |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 void CTelDMCallStateListener::DoCancel() |
|
126 { |
|
127 iProperty.Cancel(); |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CTelDMCallStateListener::IssueRequest |
|
132 // |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CTelDMCallStateListener::IssueRequest() |
|
136 { |
|
137 if ( !IsActive() ) |
|
138 { |
|
139 iProperty.Subscribe( iStatus ); |
|
140 SetActive(); |
|
141 } |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CTelDMCallStateListener::AddObserver |
|
146 // |
|
147 // ----------------------------------------------------------------------------- |
|
148 void CTelDMCallStateListener::AddObserverL( MTelDMCallStateObserver& |
|
149 aCallStateObserver ) |
|
150 { |
|
151 if ( iObserverArray.Find( &aCallStateObserver ) != KErrNone ) |
|
152 { |
|
153 User::LeaveIfError( iObserverArray.Append( &aCallStateObserver ) ); |
|
154 } |
|
155 } |
|
156 |
|
157 |
|
158 // End of File |