|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * This class connects telephony server and requests information from it. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <mmtsy_names.h> // KMmTsyModuleName |
|
23 #include <etel.h> // RTelServer |
|
24 |
|
25 // USERINCLUDE FILES |
|
26 #include "MmsConnInitLogging.h" |
|
27 #include "MmsPhoneClient.H" |
|
28 |
|
29 // EXTERNAL DATA STRUCTURES |
|
30 // EXTERNAL FUNCTION PROTOTYPES |
|
31 // CONSTANTS |
|
32 // MACROS |
|
33 // LOCAL CONSTANTS AND MACROS |
|
34 // MODULE DATA STRUCTURES |
|
35 // LOCAL FUNCTION PROTOTYPES |
|
36 // ============================== LOCAL FUNCTIONS ============================== |
|
37 // ============================== MEMBER FUNCTIONS ============================= |
|
38 |
|
39 /***************************************************** |
|
40 * Series 60 Customer / ETel |
|
41 * Series 60 ETel API |
|
42 *****************************************************/ |
|
43 /***************************************************** |
|
44 * Series 60 Customer / TSY |
|
45 * Needs customer TSY implementation |
|
46 *****************************************************/ |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CMmsPhoneClient |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CMmsPhoneClient::CMmsPhoneClient() : |
|
53 CActive( EPriorityStandard ), |
|
54 iRequestId( 0 ) |
|
55 { |
|
56 CActiveScheduler::Add( this ); |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // ConstructL |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 void CMmsPhoneClient::ConstructL() |
|
64 { |
|
65 // Connecting RTelServer and then RMobilePhone |
|
66 User::LeaveIfError( iTelServer.Connect() ); |
|
67 User::LeaveIfError( iTelServer.LoadPhoneModule( KMmTsyModuleName ) ); |
|
68 User::LeaveIfError( iMobilePhone.Open( iTelServer, KMmTsyPhoneName ) ); |
|
69 #ifdef _MMSCONNINIT_LOGGING_ |
|
70 TMmsConnInitLogger::Log( _L("CMmsPhoneClient::ConstructL OK") ); |
|
71 #endif |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // NewL |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 EXPORT_C CMmsPhoneClient* CMmsPhoneClient::NewL() |
|
79 { |
|
80 CMmsPhoneClient* self = new( ELeave ) CMmsPhoneClient; |
|
81 CleanupStack::PushL( self ); |
|
82 self->ConstructL(); |
|
83 CleanupStack::Pop(); |
|
84 return self; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // ~CMmsPhoneClient |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 CMmsPhoneClient::~CMmsPhoneClient() |
|
92 { |
|
93 Cancel(); |
|
94 |
|
95 iMobilePhone.Close(); |
|
96 iTelServer.UnloadPhoneModule( KMmTsyModuleName ); |
|
97 iTelServer.Close(); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // Roaming |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 EXPORT_C void CMmsPhoneClient::Roaming( TRequestStatus& aStatus ) |
|
105 { |
|
106 iClientStatus = &aStatus; |
|
107 aStatus = KRequestPending; |
|
108 iMobilePhone.GetNetworkRegistrationStatus( iStatus, iRegistrationStatus ); |
|
109 iRequestId = EMobilePhoneGetNetworkRegistrationStatus; |
|
110 SetActive(); |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // NetworkMode |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 EXPORT_C RMobilePhone::TMobilePhoneNetworkMode CMmsPhoneClient::NetworkMode() |
|
118 { |
|
119 TInt error = KErrNone; |
|
120 RMobilePhone::TMobilePhoneNetworkMode networkMode = RMobilePhone::ENetworkModeGsm; |
|
121 error = iMobilePhone.GetCurrentMode( networkMode ); |
|
122 if( error != KErrNone ) |
|
123 { |
|
124 #ifdef _MMSCONNINIT_LOGGING_ |
|
125 TMmsConnInitLogger::Log( _L("- ERROR: iMobilePhone.GetCurrentMode: %d"), error ); |
|
126 #endif |
|
127 return RMobilePhone::ENetworkModeUnknown; |
|
128 } |
|
129 return networkMode; |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // RunL |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void CMmsPhoneClient::RunL() |
|
137 { |
|
138 |
|
139 // Error case |
|
140 // "not supported" case must be handled separately for each request. |
|
141 // There may be a default value that must be handled in these cases |
|
142 |
|
143 if( iStatus != KErrNone && iStatus != KErrNotSupported ) |
|
144 { |
|
145 #ifdef _MMSCONNINIT_LOGGING_ |
|
146 TMmsConnInitLogger::Log( _L("- ERROR: CMmsPhoneClient::RunL completed with %d"), iStatus.Int() ); |
|
147 #endif |
|
148 User::RequestComplete( iClientStatus, iStatus.Int() ); |
|
149 // Reset the request Id |
|
150 iRequestId = 0; |
|
151 return; |
|
152 } |
|
153 |
|
154 // |
|
155 // Currently only one asynch call (roaming check): |
|
156 // |
|
157 if( iRequestId == EMobilePhoneGetNetworkRegistrationStatus ) |
|
158 // Summary: |
|
159 // - if query not supported, we say "home" |
|
160 // - if registered home, we say "home" |
|
161 // - otherwise we say "roaming" (includes all non-registered and searching states) |
|
162 { |
|
163 if ( iStatus == KErrNotSupported ) |
|
164 { |
|
165 // If network registration status query is not supported, |
|
166 // we say "home network", return 0. |
|
167 User::RequestComplete( iClientStatus, 0 ); |
|
168 } |
|
169 else |
|
170 { |
|
171 switch( iRegistrationStatus ) |
|
172 { |
|
173 case RMobilePhone::ERegisteredOnHomeNetwork: |
|
174 #ifdef _MMSCONNINIT_LOGGING_ |
|
175 TMmsConnInitLogger::Log( _L("- In Home Network") ); |
|
176 #endif |
|
177 // in Home Network, returning 0 |
|
178 User::RequestComplete( iClientStatus, 0 ); |
|
179 break; |
|
180 default: |
|
181 #ifdef _MMSCONNINIT_LOGGING_ |
|
182 TMmsConnInitLogger::Log( _L("- Roaming, in state %d"), iRegistrationStatus ); |
|
183 #endif |
|
184 // Default to roaming -> returning positive value (i.e. true) |
|
185 // If we are not sure we are at home, we say "roaming" |
|
186 // This includes all possible "searching" and "not registered" states |
|
187 User::RequestComplete( iClientStatus, 1 ); |
|
188 break; |
|
189 } |
|
190 } |
|
191 } // requestId |
|
192 |
|
193 // Reset the request Id |
|
194 iRequestId = 0; |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // DoCancel |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 void CMmsPhoneClient::DoCancel() |
|
202 { |
|
203 if( iRequestId ) |
|
204 { |
|
205 iMobilePhone.CancelAsyncRequest( iRequestId ); |
|
206 iRequestId = 0; |
|
207 } |
|
208 User::RequestComplete( iClientStatus, KErrCancel ); |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 |
|
213 // =========================== OTHER EXPORTED FUNCTIONS ======================== |
|
214 |
|
215 // End of File |