|
1 /* |
|
2 * Copyright (c) 2002 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 * CMsgErrorRoamingObserver implementation file |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32base.h> |
|
23 #include <etel.h> |
|
24 #include <etelmm.h> |
|
25 #include <mmtsy_names.h> |
|
26 |
|
27 #include "MsgErrorWatcher.h" |
|
28 #include "MsgErrorRoamingObserver.h" |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // ================= MEMBER FUNCTIONS ======================= |
|
33 |
|
34 /***************************************************** |
|
35 * Series 60 Customer / ETel |
|
36 * Series 60 ETel API |
|
37 *****************************************************/ |
|
38 |
|
39 // --------------------------------------------------------- |
|
40 // CMsgErrorRoamingObserver::CMsgErrorRoamingObserver |
|
41 // |
|
42 // C++ constructor can NOT contain any code, that |
|
43 // might leave. |
|
44 // --------------------------------------------------------- |
|
45 // |
|
46 CMsgErrorRoamingObserver::CMsgErrorRoamingObserver( CMsgErrorWatcher* aWatcher ) |
|
47 : CActive( CActive::EPriorityStandard ), |
|
48 iWatcher( aWatcher ), |
|
49 iRoaming( EFalse ), |
|
50 iRegStatus( RMobilePhone::ERegistrationUnknown ), |
|
51 iRequestId( 0 ) |
|
52 { |
|
53 CActiveScheduler::Add( this ); |
|
54 } |
|
55 |
|
56 /***************************************************** |
|
57 * Series 60 Customer / ETel |
|
58 * Series 60 ETel API |
|
59 *****************************************************/ |
|
60 |
|
61 /***************************************************** |
|
62 * Series 60 Customer / TSY |
|
63 * Needs customer TSY implementation |
|
64 *****************************************************/ |
|
65 |
|
66 // --------------------------------------------------------- |
|
67 // CMsgErrorRoamingObserver::ConstructL() |
|
68 // |
|
69 // Symbian OS default constructor can leave. |
|
70 // --------------------------------------------------------- |
|
71 // |
|
72 void CMsgErrorRoamingObserver::ConstructL() |
|
73 { |
|
74 |
|
75 User::LeaveIfError( iETelServer.Connect() ); |
|
76 User::LeaveIfError( iETelServer.LoadPhoneModule( KMmTsyModuleName ) ); |
|
77 User::LeaveIfError( iMobilePhone.Open( iETelServer, KMmTsyPhoneName ) ); |
|
78 iMobilePhone.GetNetworkRegistrationStatus( iStatus, iRegStatus ); |
|
79 iRequestId = EMobilePhoneGetNetworkRegistrationStatus; |
|
80 SetActive(); |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------- |
|
84 // CMsgErrorRoamingObserver::NewL |
|
85 // |
|
86 // Two-phased constructor. |
|
87 // --------------------------------------------------------- |
|
88 // |
|
89 CMsgErrorRoamingObserver* CMsgErrorRoamingObserver::NewL( CMsgErrorWatcher* aWatcher ) |
|
90 { |
|
91 CMsgErrorRoamingObserver* self = new ( ELeave ) |
|
92 CMsgErrorRoamingObserver( aWatcher ); |
|
93 |
|
94 CleanupStack::PushL( self ); |
|
95 self->ConstructL(); |
|
96 CleanupStack::Pop( self ); |
|
97 |
|
98 return self; |
|
99 } |
|
100 |
|
101 |
|
102 /***************************************************** |
|
103 * Series 60 Customer / ETel |
|
104 * Series 60 ETel API |
|
105 *****************************************************/ |
|
106 |
|
107 /***************************************************** |
|
108 * Series 60 Customer / TSY |
|
109 * Needs customer TSY implementation |
|
110 *****************************************************/ |
|
111 |
|
112 // --------------------------------------------------------- |
|
113 // CMsgErrorRoamingObserver::~CMsgErrorRoamingObserver |
|
114 // |
|
115 // Destructor |
|
116 // --------------------------------------------------------- |
|
117 // |
|
118 CMsgErrorRoamingObserver::~CMsgErrorRoamingObserver() |
|
119 { |
|
120 Cancel(); |
|
121 iMobilePhone.Close(); |
|
122 iETelServer.UnloadPhoneModule( KMmTsyModuleName ); |
|
123 iETelServer.Close(); |
|
124 } |
|
125 |
|
126 /***************************************************** |
|
127 * Series 60 Customer / ETel |
|
128 * Series 60 ETel API |
|
129 *****************************************************/ |
|
130 |
|
131 // --------------------------------------------------------- |
|
132 // CMsgErrorRoamingObserver::UpdateRoamingStatusL |
|
133 // |
|
134 // Checks whether roaming status has actually changed |
|
135 // --------------------------------------------------------- |
|
136 // |
|
137 void CMsgErrorRoamingObserver::UpdateRoamingStatusL() |
|
138 { |
|
139 TBool changed = EFalse; |
|
140 if ( iRoaming && iRegStatus == RMobilePhone::ERegisteredOnHomeNetwork ) |
|
141 { |
|
142 iRoaming = EFalse; |
|
143 changed = ETrue; |
|
144 } |
|
145 else if ( !iRoaming && iRegStatus == RMobilePhone::ERegisteredRoaming ) |
|
146 { |
|
147 iRoaming = ETrue; |
|
148 changed = ETrue; |
|
149 } |
|
150 else |
|
151 { |
|
152 //Nothing to do |
|
153 } |
|
154 if ( changed ) |
|
155 { |
|
156 //Inform watcher only when roaming status has changed |
|
157 iWatcher->HandleRoamingEventL( iRoaming ); |
|
158 } |
|
159 } |
|
160 |
|
161 /***************************************************** |
|
162 * Series 60 Customer / ETel |
|
163 * Series 60 ETel API |
|
164 *****************************************************/ |
|
165 |
|
166 // --------------------------------------------------------- |
|
167 // CMsgErrorRoamingObserver::Start |
|
168 // |
|
169 // Starts the active object |
|
170 // --------------------------------------------------------- |
|
171 // |
|
172 void CMsgErrorRoamingObserver::Start() |
|
173 { |
|
174 if ( !IsActive() ) |
|
175 { |
|
176 iMobilePhone.NotifyNetworkRegistrationStatusChange( iStatus, iRegStatus ); |
|
177 iRequestId = EMobilePhoneNotifyNetworkRegistrationStatusChange; |
|
178 SetActive(); |
|
179 } |
|
180 } |
|
181 |
|
182 /***************************************************** |
|
183 * Series 60 Customer / ETel |
|
184 * Series 60 ETel API |
|
185 *****************************************************/ |
|
186 |
|
187 // --------------------------------------------------------- |
|
188 // CMsgErrorRoamingObserver::DoCancel |
|
189 // |
|
190 // From active object framework |
|
191 // --------------------------------------------------------- |
|
192 // |
|
193 void CMsgErrorRoamingObserver::DoCancel() |
|
194 { |
|
195 if ( iRequestId ) |
|
196 { |
|
197 iMobilePhone.CancelAsyncRequest( iRequestId ); |
|
198 iRequestId = 0; |
|
199 } |
|
200 } |
|
201 |
|
202 /***************************************************** |
|
203 * Series 60 Customer / ETel |
|
204 * Series 60 ETel API |
|
205 *****************************************************/ |
|
206 |
|
207 // --------------------------------------------------------- |
|
208 // CMsgErrorRoamingObserver::RunL |
|
209 // |
|
210 // From active object framework |
|
211 // --------------------------------------------------------- |
|
212 // |
|
213 void CMsgErrorRoamingObserver::RunL() |
|
214 { |
|
215 iRequestId = 0; |
|
216 TInt status = iStatus.Int(); |
|
217 if ( status < 0 ) |
|
218 { |
|
219 iRegStatus = RMobilePhone::ERegistrationUnknown; |
|
220 } |
|
221 TRAP_IGNORE( UpdateRoamingStatusL() ); |
|
222 Start(); |
|
223 } |
|
224 |
|
225 // ================= OTHER EXPORTED FUNCTIONS ============== |
|
226 |
|
227 // End of File |