37
|
1 |
/*
|
|
2 |
* Copyright (c) 2003 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: Sim State Monitoring class methods implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include "cpesimstatemonitor.h"
|
|
22 |
#include "mpephonemodelinternal.h"
|
|
23 |
#include <startupdomainpskeys.h>
|
|
24 |
#include <talogger.h>
|
|
25 |
|
|
26 |
|
|
27 |
// ================= MEMBER FUNCTIONS =======================================
|
|
28 |
|
|
29 |
// -----------------------------------------------------------------------------
|
|
30 |
// CPESimStateMonitor::CPESimStateMonitor
|
|
31 |
// C++ default constructor can NOT contain any code, that
|
|
32 |
// might leave.
|
|
33 |
// -----------------------------------------------------------------------------
|
|
34 |
//
|
|
35 |
CPESimStateMonitor::CPESimStateMonitor(
|
|
36 |
MPEPhoneModelInternal& aModel,
|
|
37 |
const TEvent aEvent )
|
|
38 |
: CActive( EPriorityStandard ),
|
|
39 |
iModel( aModel ),
|
|
40 |
iSimState( EPESimStatusUninitialized ),
|
|
41 |
iStartUp( ETrue )
|
|
42 |
{
|
|
43 |
if ( aEvent == EEventSimStatus )
|
|
44 |
{
|
|
45 |
iPropertyKey = KPSSimStatus;
|
|
46 |
}
|
|
47 |
else
|
|
48 |
{
|
|
49 |
iPropertyKey = KPSSimChanged;
|
|
50 |
}
|
|
51 |
}
|
|
52 |
|
|
53 |
// -----------------------------------------------------------------------------
|
|
54 |
// CPESimStateMonitor::ConstructL
|
|
55 |
// Symbian 2nd phase constructor can leave.
|
|
56 |
// -----------------------------------------------------------------------------
|
|
57 |
//
|
|
58 |
void CPESimStateMonitor::ConstructL()
|
|
59 |
{
|
|
60 |
TEFLOGSTRING( KTAMESOUT, "PE CPESimStateMonitor::ConstructL start" );
|
|
61 |
|
|
62 |
RProperty::TType type( RProperty::EInt );
|
|
63 |
TInt err = iProperty.Define( KPSUidStartup, iPropertyKey, type );
|
|
64 |
|
|
65 |
//An error of KErrAlready exists should be ignored, as this only
|
|
66 |
//indicates that some other code int system is also interested in the
|
|
67 |
//value and has created the property.
|
|
68 |
if ( err != KErrNone && err != KErrAlreadyExists )
|
|
69 |
{
|
|
70 |
User::Leave( err );
|
|
71 |
}
|
|
72 |
User::LeaveIfError( iProperty.Attach( KPSUidStartup, iPropertyKey ) );
|
|
73 |
|
|
74 |
// NOTE StartMonitoring() is not called here and this is intentional.
|
|
75 |
// It is undesirable to send out messages before initialization is complete.
|
|
76 |
// The first completion of this monitor is achieved by calling Start() from
|
|
77 |
// MPEPhoneModelInternal::StepL()
|
|
78 |
|
|
79 |
TEFLOGSTRING( KTAMESOUT, "PE CPESimStateMonitor::ConstructL complete" );
|
|
80 |
}
|
|
81 |
|
|
82 |
// -----------------------------------------------------------------------------
|
|
83 |
// CPESimStateMonitor::NewL
|
|
84 |
// Two-phased constructor.
|
|
85 |
// -----------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
CPESimStateMonitor* CPESimStateMonitor::NewL(
|
|
88 |
MPEPhoneModelInternal& aModel,
|
|
89 |
const TEvent aEvent )
|
|
90 |
{
|
|
91 |
TEFLOGSTRING2( KTAOBJECT, "PE CPESimStateMonitor::Newl %d", aEvent );
|
|
92 |
CPESimStateMonitor* self = new ( ELeave ) CPESimStateMonitor( aModel, aEvent );
|
|
93 |
CleanupStack::PushL( self );
|
|
94 |
self->ConstructL();
|
|
95 |
CleanupStack::Pop( self );
|
|
96 |
TEFLOGSTRING( KTAMESOUT, "PE CPESimStateMonitor::NewL complete" );
|
|
97 |
|
|
98 |
return self;
|
|
99 |
}
|
|
100 |
|
|
101 |
// Destructor
|
|
102 |
CPESimStateMonitor::~CPESimStateMonitor()
|
|
103 |
{
|
|
104 |
Cancel();
|
|
105 |
iProperty.Close();
|
|
106 |
}
|
|
107 |
|
|
108 |
// -----------------------------------------------------------------------------
|
|
109 |
// CPESimStateMonitor::Start
|
|
110 |
// Completes monitor to finish initialization
|
|
111 |
// -----------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
void CPESimStateMonitor::Start()
|
|
114 |
{
|
|
115 |
if ( !IsActive() )
|
|
116 |
{
|
|
117 |
CActiveScheduler::Add( this );
|
|
118 |
SetActive();
|
|
119 |
TRequestStatus* status = &iStatus ;
|
|
120 |
User::RequestComplete( status, KErrNone );
|
|
121 |
}
|
|
122 |
}
|
|
123 |
|
|
124 |
// -----------------------------------------------------------------------------
|
|
125 |
// CPESimStateMonitor::SimState
|
|
126 |
// Returns Sim state.
|
|
127 |
// -----------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
TPESimState CPESimStateMonitor::SimState() const
|
|
130 |
{
|
|
131 |
return static_cast<TPESimState>( iSimState );
|
|
132 |
}
|
|
133 |
|
|
134 |
// -----------------------------------------------------------------------------
|
|
135 |
// CPESimStateMonitor::StartMonitoring
|
|
136 |
// Starts monitoring Sim state
|
|
137 |
// -----------------------------------------------------------------------------
|
|
138 |
//
|
|
139 |
void CPESimStateMonitor::StartMonitoring()
|
|
140 |
{
|
|
141 |
iProperty.Subscribe( iStatus );
|
|
142 |
SetActive();
|
|
143 |
}
|
|
144 |
|
|
145 |
// -----------------------------------------------------------------------------
|
|
146 |
// CPESimStateMonitor::DoCancel
|
|
147 |
// Callback method from CActive.
|
|
148 |
// -----------------------------------------------------------------------------
|
|
149 |
//
|
|
150 |
void CPESimStateMonitor::DoCancel()
|
|
151 |
{
|
|
152 |
iProperty.Cancel();
|
|
153 |
}
|
|
154 |
|
|
155 |
// -----------------------------------------------------------------------------
|
|
156 |
// CPESimStateMonitor::RunL
|
|
157 |
// In startup reads Sim state from System Agent, otherwise it is called
|
|
158 |
// when Sim state is changed.
|
|
159 |
// -----------------------------------------------------------------------------
|
|
160 |
//
|
|
161 |
void CPESimStateMonitor::RunL()
|
|
162 |
{
|
|
163 |
TInt status = iStatus.Int();
|
|
164 |
// resubscribe before processing new value to prevent missing updates
|
|
165 |
StartMonitoring();
|
|
166 |
|
|
167 |
iProperty.Get( KPSUidStartup, iPropertyKey, iSimState );
|
|
168 |
|
|
169 |
if ( iStartUp )
|
|
170 |
{
|
|
171 |
iStartUp = EFalse;
|
|
172 |
|
|
173 |
if ( iPropertyKey == KPSSimStatus )
|
|
174 |
{
|
|
175 |
if( iSimState != EPESimStatusUninitialized && iSimState != EPESimNotSupported )
|
|
176 |
{
|
|
177 |
iModel.SendMessage( MEngineMonitor::EPEMessageSIMStateChanged );
|
|
178 |
}
|
|
179 |
}
|
|
180 |
else
|
|
181 |
{
|
|
182 |
iModel.SendMessage( MEngineMonitor::EPEMessageSIMChanged );
|
|
183 |
}
|
|
184 |
}
|
|
185 |
else // Sim or Sim status has changed
|
|
186 |
{
|
|
187 |
if ( status == KErrNone )
|
|
188 |
{
|
|
189 |
TEFLOGSTRING3( KTAMESINT,
|
|
190 |
"PE CPESimStateMonitor::RunL, event: %d, property: %d"
|
|
191 |
, iPropertyKey
|
|
192 |
, iSimState );
|
|
193 |
|
|
194 |
if ( iPropertyKey == KPSSimStatus )
|
|
195 |
{
|
|
196 |
iModel.SendMessage( MEngineMonitor::EPEMessageSIMStateChanged );
|
|
197 |
}
|
|
198 |
else
|
|
199 |
{
|
|
200 |
if ( iSimState == ESimChanged )
|
|
201 |
{
|
|
202 |
iModel.SendMessage( MEngineMonitor::EPEMessageSIMChanged );
|
|
203 |
}
|
|
204 |
}
|
|
205 |
}
|
|
206 |
else
|
|
207 |
{
|
|
208 |
TEFLOGSTRING3( KTAERROR, "PE CPESimStateMonitor::RunL, event: %d, status: %d", iPropertyKey, status );
|
|
209 |
}
|
|
210 |
}
|
|
211 |
}
|
|
212 |
|
|
213 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
214 |
|
|
215 |
// None
|
|
216 |
|
|
217 |
// End of File
|