|
1 /* |
|
2 * Copyright (c) 2002-2008 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: This module contains the implementation of CPEClientServices class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cpeclientcallrequestmonitor.h" |
|
21 #include "cpeclientcommandhandlermonitor.h" |
|
22 #include "cpeclientemergencycallmonitor.h" |
|
23 #include "cpeclientservices.h" |
|
24 #include "cpedevicemodehandler.h" |
|
25 #include "cpemessagehandler.h" |
|
26 #include "mpecallhandling.h" |
|
27 #include "mpephonemodelinternal.h" |
|
28 #include <apgtask.h> |
|
29 #include <CPhCltCallNotify.h> |
|
30 #include <CPhCltEmergencyCall.h> |
|
31 #include <CPhCltUssd.h> |
|
32 #include <mpedatastore.h> |
|
33 #include <talogger.h> |
|
34 |
|
35 |
|
36 // ================= MEMBER FUNCTIONS ======================= |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CPEClientServices::CPEClientServices |
|
40 // C++ default constructor can NOT contain any code, that |
|
41 // might leave. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CPEClientServices::CPEClientServices( |
|
45 MPEPhoneModelInternal& aModel, |
|
46 CPEMessageHandler& aMessageHandler, |
|
47 MPECallHandling& aCallHandling, |
|
48 CPEManualCallControlHandler& aManualCallControlHandler |
|
49 ) : iModel( aModel ), |
|
50 iMessageHandler( aMessageHandler ), |
|
51 iCallHandling( aCallHandling ), |
|
52 iManualCallControlHandler( aManualCallControlHandler ) |
|
53 { |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CPEClientServices::ConstructL |
|
58 // Symbian OS default constructor may leave. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void CPEClientServices::ConstructL() |
|
62 { |
|
63 TEFLOGSTRING( KTAOBJECT, "PE CPEClientServices::ConstructL()" ); |
|
64 |
|
65 User::LeaveIfError( iPhoneServer.Connect( ) ); |
|
66 |
|
67 // Need to call CreateAll so that Phone Server creates all managers |
|
68 // (f.ex. USSD manager). Otherwise USSD requests/notifications don't |
|
69 // get through unless USSD request is sent from Mobile Terminal first. |
|
70 TRequestStatus phoneServerStatus; |
|
71 iPhoneServer.CreateAll( phoneServerStatus ); |
|
72 User::WaitForRequest( phoneServerStatus ); |
|
73 User::LeaveIfError( phoneServerStatus.Int() ); |
|
74 |
|
75 iEmergency = CPhCltEmergencyCall::NewL( NULL ); |
|
76 |
|
77 iCallNotifier = CPhCltCallNotify::NewL(); |
|
78 User::LeaveIfError( iCallNotifier->Open( iPhoneServer ) ); |
|
79 |
|
80 iClientCallRequestMonitor = CPEClientCallRequestMonitor::NewL( |
|
81 iModel, |
|
82 *iCallNotifier ); |
|
83 |
|
84 iClientEmergencyMonitor = CPEClientEmergencyCallMonitor::NewL( |
|
85 iModel, |
|
86 *iCallNotifier ); |
|
87 |
|
88 iClientCommandHandlerMonitor = CPEClientCommandHandlerMonitor::NewL( |
|
89 iCallHandling, |
|
90 iMessageHandler, |
|
91 iModel, |
|
92 iPhoneServer, |
|
93 iManualCallControlHandler ); |
|
94 |
|
95 iDeviceModeHandler = CPEDeviceModeHandler::NewL( |
|
96 iCallHandling, |
|
97 iMessageHandler ); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CPEClientServices::NewL |
|
102 // Two-phased constructor. |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 CPEClientServices* CPEClientServices::NewL( |
|
106 MPEPhoneModelInternal& aModel, |
|
107 CPEMessageHandler& aMessageHandler, |
|
108 MPECallHandling& aCallHandling, |
|
109 CPEManualCallControlHandler& aManualCallControlHandler ) |
|
110 { |
|
111 TEFLOGSTRING( KTAOBJECT, "PE CPEClientServices::NewL()" ); |
|
112 |
|
113 CPEClientServices* self = new ( ELeave ) CPEClientServices( |
|
114 aModel, |
|
115 aMessageHandler, |
|
116 aCallHandling, |
|
117 aManualCallControlHandler ); |
|
118 |
|
119 CleanupStack::PushL( self ); |
|
120 self->ConstructL(); |
|
121 CleanupStack::Pop( self ); |
|
122 return (self); |
|
123 } |
|
124 |
|
125 |
|
126 // Destructor |
|
127 CPEClientServices::~CPEClientServices () |
|
128 { |
|
129 delete iClientCommandHandlerMonitor; |
|
130 delete iClientCallRequestMonitor; |
|
131 delete iDeviceModeHandler; |
|
132 |
|
133 // Cancel any outstanding USSD requests |
|
134 if ( iUssdClient ) |
|
135 { |
|
136 iUssdClient->SendUssdCancel(); |
|
137 } |
|
138 delete iUssdClient; |
|
139 delete iClientEmergencyMonitor; |
|
140 iCallNotifier->Close(); |
|
141 delete iCallNotifier; |
|
142 delete iEmergency; |
|
143 iPhoneServer.Close(); |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CPEClientServices::IsEmergencyPhoneNumber |
|
148 // Check if the given telephone number is an emergency number. |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 TInt CPEClientServices::IsEmergencyPhoneNumber( |
|
152 TPhCltTelephoneNumber& aNumber, |
|
153 TBool& aIsEmergencyNumber ) |
|
154 { |
|
155 TInt errorCode = iEmergency->IsEmergencyPhoneNumber( aNumber, |
|
156 aIsEmergencyNumber ); |
|
157 return errorCode; |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CPEClientServices::SendUssd |
|
162 // Process USSD request |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 TInt CPEClientServices::SendUssd( |
|
166 const TDesC& aString ) // USSD string to be sent. |
|
167 { |
|
168 TInt errorCode( KErrNone ); |
|
169 |
|
170 TRAP( errorCode, ( iUssdClient = CPhCltUssd::NewL() ) ); |
|
171 if( errorCode == KErrNone ) |
|
172 { |
|
173 iString.Set( aString ); |
|
174 iModel.SendMessage( MEngineMonitor::EPEMessageIssuingUSSDRequest ); |
|
175 errorCode = iUssdClient->SendUssd( iString ); |
|
176 iModel.SendMessage( MEngineMonitor::EPEMessageIssuedUSSDRequest ); |
|
177 TEFLOGSTRING2( KTAINT, |
|
178 "PE CPEClientServices::SendUssd, error code: %d", errorCode ); |
|
179 |
|
180 delete iUssdClient; |
|
181 iUssdClient = NULL; |
|
182 } |
|
183 else |
|
184 { |
|
185 TEFLOGSTRING( KTAERROR, |
|
186 "PE CPECLIENTSERVICES::SENDUSSD > CPHCLTUSSD::NEWL FAILED" ); |
|
187 } |
|
188 |
|
189 return errorCode; |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CPEClientServices::StartMonitoring |
|
194 // Start monitoring |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 void CPEClientServices::StartMonitoring() |
|
198 { |
|
199 iClientCallRequestMonitor->StartMonitoring(); |
|
200 iClientEmergencyMonitor->StartMonitoring(); |
|
201 iClientCommandHandlerMonitor->Start(); |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CPEClientServices::CallRequestMonitor |
|
206 // Returns MPEClientCallRequestMonitor object |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 MPEClientCallRequestMonitor* CPEClientServices::CallRequestMonitor() |
|
210 { |
|
211 // Both monitors are accessed when in RunL, only in Sat call case call |
|
212 // request monitor's SendRespond method is called later when monitoring |
|
213 // already started. |
|
214 if ( !iClientEmergencyMonitor->IsActive() ) |
|
215 { |
|
216 return iClientEmergencyMonitor; |
|
217 } |
|
218 return iClientCallRequestMonitor; |
|
219 } |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // CPEClientServices::CommandHandlerMonitor |
|
223 // Returns CPEClientCommandHandlerMonitor object |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 CPEClientCommandHandlerMonitor* CPEClientServices::CommandHandlerMonitor() |
|
227 { |
|
228 return iClientCommandHandlerMonitor; |
|
229 } |
|
230 |
|
231 // End of File |