|
1 /* |
|
2 * Copyright (c) 2006-2009 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: ConnMon Telephony watcher. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <mmtsy_names.h> |
|
19 #include <pcktcs.h> |
|
20 |
|
21 #include "connmontelnoti.h" |
|
22 #include "ConnMonDef.h" |
|
23 #include "log.h" |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CConnMonTelNotifier::NewL |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CConnMonTelNotifier* CConnMonTelNotifier::NewL( |
|
32 MConnMonTelephonyObserver& aObserver, |
|
33 RMobilePhone* aMobilePhone ) |
|
34 { |
|
35 CConnMonTelNotifier* self = new( ELeave ) CConnMonTelNotifier( aObserver, aMobilePhone ); |
|
36 |
|
37 self->Construct(); |
|
38 return self; |
|
39 } |
|
40 |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CConnMonTelNotifier::CConnMonTelNotifier |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CConnMonTelNotifier::CConnMonTelNotifier( |
|
47 MConnMonTelephonyObserver& aObserver, |
|
48 RMobilePhone* aMobilePhone ) |
|
49 : |
|
50 CActive( EConnMonPriorityNormal ), |
|
51 iMobilePhone( aMobilePhone ), |
|
52 iVoiceCallActive( EFalse ), |
|
53 iObserver( aObserver ), |
|
54 iSendEvents( EFalse ) |
|
55 { |
|
56 CActiveScheduler::Add( this ); |
|
57 } |
|
58 |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CConnMonTelNotifier::~CConnMonTelNotifier |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CConnMonTelNotifier::~CConnMonTelNotifier() |
|
65 { |
|
66 //LOGENTRFN("CConnMonTelNotifier::~CConnMonTelNotifier()") |
|
67 Cancel(); |
|
68 iLine.Close(); |
|
69 //LOGEXITFN("CConnMonTelNotifier::~CConnMonTelNotifier()") |
|
70 } |
|
71 |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CConnMonTelNotifier::Construct |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CConnMonTelNotifier::Construct() |
|
78 { |
|
79 //LOGENTRFN("CConnMonTelNotifier::Construct()") |
|
80 |
|
81 TInt ret = iLine.Open( *iMobilePhone, KMmTsyVoice1LineName ); |
|
82 iLine.GetStatus( iCallStatus ); |
|
83 |
|
84 if ( iCallStatus == RCall::EStatusDialling || |
|
85 iCallStatus == RCall::EStatusRinging || |
|
86 iCallStatus == RCall::EStatusAnswering || |
|
87 iCallStatus == RCall::EStatusConnecting || |
|
88 iCallStatus == RCall::EStatusConnected || |
|
89 iCallStatus == RCall::EStatusHangingUp ) |
|
90 { |
|
91 LOGIT1("Voice line status: active (%d)", iCallStatus) |
|
92 iVoiceCallActive = ETrue; |
|
93 } |
|
94 else if ( iCallStatus == RCall::EStatusIdle || |
|
95 iCallStatus == RCall::EStatusUnknown ) |
|
96 { |
|
97 LOGIT1("Voice line status: not active (%d)", iCallStatus) |
|
98 iVoiceCallActive = EFalse; |
|
99 } |
|
100 else |
|
101 { |
|
102 LOGIT1("Voice line status: unknown (%d)", iCallStatus ) |
|
103 iVoiceCallActive = EFalse; |
|
104 } |
|
105 iLine.NotifyStatusChange( iStatus, iCallStatus ); |
|
106 SetActive(); |
|
107 |
|
108 LOGIT("Created CConnMonTelNotifier") |
|
109 //LOGEXITFN("CConnMonTelNotifier::Construct()") |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CConnMonTelNotifier::IsCallActive |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 TBool CConnMonTelNotifier::IsCallActive() const |
|
118 { |
|
119 LOGIT("CConnMonTelNotifier::IsCallActive") |
|
120 |
|
121 return iVoiceCallActive; |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CConnMonTelNotifier::Receive |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void CConnMonTelNotifier::Receive() |
|
129 { |
|
130 iSendEvents = ETrue; |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CConnMonTelNotifier::CancelNotificatications |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 void CConnMonTelNotifier::CancelNotifications() |
|
138 { |
|
139 iSendEvents = EFalse; |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CConnMonTelNotifier::RunL |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 void CConnMonTelNotifier::RunL() |
|
147 { |
|
148 LOGENTRFN("CConnMonTelNotifier::RunL()") |
|
149 |
|
150 TBool stateChanged( EFalse ); |
|
151 if ( KErrNone == iStatus.Int() ) |
|
152 { |
|
153 LOGIT1("Server: CConnMonTelNotifier::RunL - Call status <%d>", iCallStatus ) |
|
154 |
|
155 if ( iCallStatus == RCall::EStatusDialling || |
|
156 iCallStatus == RCall::EStatusRinging || |
|
157 iCallStatus == RCall::EStatusAnswering || |
|
158 iCallStatus == RCall::EStatusConnecting || |
|
159 iCallStatus == RCall::EStatusConnected || |
|
160 iCallStatus == RCall::EStatusHangingUp ) |
|
161 { |
|
162 // Do not notify, if state doesn't change |
|
163 if ( EFalse == iVoiceCallActive ) |
|
164 { |
|
165 stateChanged = ETrue; |
|
166 iVoiceCallActive = ETrue; |
|
167 |
|
168 LOGIT("Server: CConnMonTelNotifier::RunL - Voice Call Active") |
|
169 } |
|
170 } |
|
171 else |
|
172 { |
|
173 // Do not notify, if state doesn't change |
|
174 if ( EFalse != iVoiceCallActive ) |
|
175 { |
|
176 stateChanged = ETrue; |
|
177 iVoiceCallActive = EFalse; |
|
178 |
|
179 LOGIT("Server: CConnMonTelNotifier::RunL - Voice Call Not Active") |
|
180 } |
|
181 } |
|
182 // Does the observer want to listen to the events |
|
183 // and has the state changed from the last known state |
|
184 if ( iSendEvents && stateChanged ) |
|
185 { |
|
186 LOGIT("Server: CConnMonTelNotifier::RunL - Notifying observer") |
|
187 |
|
188 iObserver.PhoneLineStatusChange(); |
|
189 } |
|
190 iLine.NotifyStatusChange( iStatus, iCallStatus ); |
|
191 SetActive(); |
|
192 } |
|
193 else |
|
194 { |
|
195 // Log error and stop |
|
196 LOGIT1("Server: CConnMonTelNotifier::RunL - Error <%d>", iStatus.Int() ) |
|
197 } |
|
198 LOGEXITFN("CConnMonTelNotifier::RunL()") |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CConnMonTelNotifier::DoCancel |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 void CConnMonTelNotifier::DoCancel() |
|
206 { |
|
207 LOGIT("CConnMonTelNotifier::DoCancel") |
|
208 |
|
209 iLine.NotifyStatusChangeCancel(); |
|
210 } |
|
211 |
|
212 // End-of-file |