1 /* |
|
2 * Copyright (c) 2005-2007 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: Provide interface for the client requestin availability class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "musavanetworkavailability.h" |
|
21 #include "musavaavailabilityobserver.h" |
|
22 #include "musavasettingsimp.h" |
|
23 #include "musavanetworkavailability.h" |
|
24 #include "mussesseioninformationapi.h" |
|
25 #include "musavaobserver.h" |
|
26 #include "musavasharedobject.h" |
|
27 #include "muslogger.h" |
|
28 #include "musavacalleventmonitor.h" |
|
29 |
|
30 #include <e32base.h> |
|
31 |
|
32 |
|
33 CMusAvaNetworkAvailability* CMusAvaNetworkAvailability::NewL( |
|
34 MMusAvaAvailabilityObserver& aObserver, |
|
35 CMusAvaSettingsImp& aSettings ) |
|
36 { |
|
37 CMusAvaNetworkAvailability* self = |
|
38 CMusAvaNetworkAvailability::NewLC( |
|
39 aObserver, |
|
40 aSettings ); |
|
41 |
|
42 CleanupStack::Pop( self ); |
|
43 return self; |
|
44 } |
|
45 |
|
46 |
|
47 CMusAvaNetworkAvailability* CMusAvaNetworkAvailability::NewLC( |
|
48 MMusAvaAvailabilityObserver& aObserver, |
|
49 CMusAvaSettingsImp& aSettings ) |
|
50 { |
|
51 CMusAvaNetworkAvailability* self = |
|
52 new( ELeave ) CMusAvaNetworkAvailability( |
|
53 aObserver, |
|
54 aSettings ); |
|
55 |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 return self; |
|
59 } |
|
60 |
|
61 |
|
62 CMusAvaNetworkAvailability::~CMusAvaNetworkAvailability() |
|
63 { |
|
64 if ( iPhoneStatus ) |
|
65 { |
|
66 iPhoneStatus->Cancel(); |
|
67 } |
|
68 delete iPhoneStatus; |
|
69 iPhoneStatus = NULL; |
|
70 } |
|
71 |
|
72 |
|
73 CMusAvaNetworkAvailability::CMusAvaNetworkAvailability( |
|
74 MMusAvaAvailabilityObserver& aObserver, |
|
75 CMusAvaSettingsImp& aSettings ) |
|
76 :CMusAvaAvailability( aObserver ), |
|
77 iSettings( aSettings ) |
|
78 { |
|
79 } |
|
80 |
|
81 |
|
82 void CMusAvaNetworkAvailability::ConstructL() |
|
83 { |
|
84 iPhoneStatus = CMusAvaCallEventMonitor::NewL( *this ); |
|
85 } |
|
86 |
|
87 |
|
88 // ------------------------------------------------------------------------- |
|
89 // Starts the loopy execution. |
|
90 // ------------------------------------------------------------------------- |
|
91 // |
|
92 void CMusAvaNetworkAvailability::DoExecuteL() |
|
93 { |
|
94 MUS_LOG( "mus: [MUSAVA] -> CMusAvaNetworkAvailability::\ |
|
95 Execute()" ) |
|
96 |
|
97 // read the current value and subscribe for changes |
|
98 // that's done in RunL |
|
99 switch (iPhoneStatus->CallStatusL()) |
|
100 { |
|
101 case NMusSessionInformationApi::ECallConnected: |
|
102 { |
|
103 TBuf<CMusAvaCallEventMonitor::KMusTelNumberMaxLength> telNumber; |
|
104 iPhoneStatus->GetTelNumberL( telNumber ); |
|
105 iSettings.SetTelNumberL( telNumber ); |
|
106 iSettings.SetCallDirection( iPhoneStatus->CallDirectionL() ); |
|
107 iSettings.SetCallPrivacy( iPhoneStatus->CallPrivacyL() ); |
|
108 |
|
109 SetState( MMusAvaObserver::EMusAvaStatusAvailable ); |
|
110 break; |
|
111 } |
|
112 case NMusSessionInformationApi::ECallHold: |
|
113 SetState( MMusAvaObserver::EMusAvaStatusCallOnHold ); |
|
114 break; |
|
115 case NMusSessionInformationApi::EConferenceCall: |
|
116 SetState( MMusAvaObserver::EMusAvaStatusConferenceCall ); |
|
117 break; |
|
118 case NMusSessionInformationApi::ENoCall: |
|
119 SetState( MMusAvaObserver::EMusAvaStatusNoCall ); |
|
120 break; |
|
121 default: |
|
122 SetState( MMusAvaObserver::EMusAvaStatusNoCall ); |
|
123 break; |
|
124 } |
|
125 |
|
126 // subscribe for the future changes. |
|
127 iPhoneStatus->StartMonitoringL(); |
|
128 |
|
129 MUS_LOG( "mus: [MUSAVA] <- CMusAvaNetworkAvailability::\ |
|
130 ExecutePatternL()" ) |
|
131 } |
|
132 |
|
133 |
|
134 void CMusAvaNetworkAvailability::Stop() |
|
135 { |
|
136 iPhoneStatus->Cancel(); |
|
137 SetState( MMusAvaObserver::EMusAvaStatusNotExecuted ); |
|
138 } |
|
139 |
|
140 |
|
141 MMusAvaObserver::TAvailabilityName CMusAvaNetworkAvailability::Name() |
|
142 { |
|
143 return MMusAvaObserver::EMusAvaNameNetworkStatus; |
|
144 } |
|
145 |
|
146 // ------------------------------------------------------------------------- |
|
147 // This function is called when a cs call is connected. |
|
148 // ------------------------------------------------------------------------- |
|
149 // |
|
150 void CMusAvaNetworkAvailability::CallConnectedL( const TDesC& aTelNumber ) |
|
151 { |
|
152 MUS_LOG( "mus: [MUSAVA] \ |
|
153 -> CMusAvaNetworkAvailability::CallConnectedL()" ) |
|
154 // try to resolve to contact information of the remote host |
|
155 |
|
156 iSettings.SetTelNumberL( aTelNumber ); |
|
157 iSettings.SetCallDirection( iPhoneStatus->CallDirectionL() ); |
|
158 iSettings.SetCallPrivacy( iPhoneStatus->CallPrivacyL() ); |
|
159 SetState( MMusAvaObserver::EMusAvaStatusAvailable ); |
|
160 |
|
161 MUS_LOG( "mus: [MUSAVA] \ |
|
162 <- CMusAvaNetworkAvailability::CallConnectedL()" ) |
|
163 } |
|
164 |
|
165 |
|
166 // ------------------------------------------------------------------------- |
|
167 // This function is called when a cs call goes into a state |
|
168 // that is not connected. |
|
169 // ------------------------------------------------------------------------- |
|
170 // |
|
171 void CMusAvaNetworkAvailability::ConferenceCallL() |
|
172 { |
|
173 MUS_LOG( "mus: [MUSAVA] \ |
|
174 -> CMusAvaNetworkAvailability::ConferenceCallL()" ) |
|
175 //Report line status |
|
176 SetState( MMusAvaObserver::EMusAvaStatusConferenceCall ); |
|
177 MUS_LOG( "mus: [MUSAVA] \ |
|
178 <- CMusAvaNetworkAvailability::ConferenceCallL()" ) |
|
179 } |
|
180 |
|
181 |
|
182 // ------------------------------------------------------------------------- |
|
183 // This function is called when a cs call goes hold |
|
184 // ------------------------------------------------------------------------- |
|
185 // |
|
186 void CMusAvaNetworkAvailability::CallHoldL( const TDesC& aTelNumber ) |
|
187 { |
|
188 MUS_LOG( "mus: [MUSAVA] -> CMusAvaNetworkAvailability::CallHoldL()" ) |
|
189 //Report line status |
|
190 iSettings.SetTelNumberL( aTelNumber ); |
|
191 iSettings.SetCallDirection( iPhoneStatus->CallDirectionL() ); |
|
192 iSettings.SetCallPrivacy( iPhoneStatus->CallPrivacyL() ); |
|
193 SetState( MMusAvaObserver::EMusAvaStatusCallOnHold ); |
|
194 MUS_LOG( "mus: [MUSAVA] <- CMusAvaNetworkAvailability::CallHoldL()" ) |
|
195 } |
|
196 |
|
197 |
|
198 // ------------------------------------------------------------------------- |
|
199 // This function is called when a cs call goes into a state |
|
200 // that is not connected. |
|
201 // ------------------------------------------------------------------------- |
|
202 // |
|
203 void CMusAvaNetworkAvailability::NoActiveCallL() |
|
204 { |
|
205 MUS_LOG( "mus: [MUSAVA] -> CMusAvaNetworkAvailability::NoActiveCallL()" ) |
|
206 |
|
207 iSettings.SetTelNumberL( KNullDesC() ); |
|
208 |
|
209 //Report line status |
|
210 //Availability status |
|
211 SetState( MMusAvaObserver::EMusAvaStatusNoCall ); |
|
212 |
|
213 MUS_LOG( "mus: [MUSAVA] <- CMusAvaNetworkAvailability::NoActiveCallL()" ) |
|
214 } |
|