37
|
1 |
/*
|
|
2 |
* Copyright (c) 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: Utility class for waiting idle.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "ctelewaitingidle.h"
|
|
21 |
#include "cphonerecoverysystem.h"
|
|
22 |
#include "phonelogger.h"
|
|
23 |
#include <startupdomainpskeys.h>
|
|
24 |
|
|
25 |
|
|
26 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
27 |
// -----------------------------------------------------------------------------
|
|
28 |
// CTeleWaitingIdle::CTeleWaitingIdle
|
|
29 |
// C++ default constructor can NOT contain any code, that
|
|
30 |
// might leave.
|
|
31 |
// -----------------------------------------------------------------------------
|
|
32 |
//
|
|
33 |
CTeleWaitingIdle::CTeleWaitingIdle(
|
|
34 |
TInt aPriority,
|
|
35 |
CTeleRecoverySystem& aRecoverySystem ) :
|
|
36 |
CActive( aPriority),
|
|
37 |
iRecoverySystem( aRecoverySystem )
|
|
38 |
{
|
|
39 |
CActiveScheduler::Add( this );
|
|
40 |
}
|
|
41 |
|
|
42 |
// -----------------------------------------------------------------------------
|
|
43 |
// CTeleWaitingIdle::NewL
|
|
44 |
// Two-phased constructor.
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
CTeleWaitingIdle* CTeleWaitingIdle::NewL( TInt aPriority,
|
|
48 |
CTeleRecoverySystem& aRecoverySystem )
|
|
49 |
{
|
|
50 |
CTeleWaitingIdle* self = new( ELeave ) CTeleWaitingIdle(
|
|
51 |
aPriority, aRecoverySystem );
|
|
52 |
return self;
|
|
53 |
}
|
|
54 |
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
// CTeleWaitingIdle::~CTeleWaitingIdle()
|
|
57 |
// (other items were commented in a header).
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
CTeleWaitingIdle::~CTeleWaitingIdle()
|
|
61 |
{
|
|
62 |
Cancel();
|
|
63 |
|
|
64 |
if ( iProperty.Handle() )
|
|
65 |
{
|
|
66 |
iProperty.Close();
|
|
67 |
}
|
|
68 |
}
|
|
69 |
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
// CTeleWaitingIdle::DoCancel
|
|
72 |
// (other items were commented in a header).
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
void CTeleWaitingIdle::DoCancel()
|
|
76 |
{
|
|
77 |
if ( iProperty.Handle() )
|
|
78 |
{
|
|
79 |
iProperty.Cancel();
|
|
80 |
}
|
|
81 |
}
|
|
82 |
|
|
83 |
// -----------------------------------------------------------------------------
|
|
84 |
// CTeleWaitingIdle::RunL
|
|
85 |
// (other items were commented in a header).
|
|
86 |
// -----------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
void CTeleWaitingIdle::RunL()
|
|
89 |
{
|
|
90 |
// Phone_PRINT("WI.RunL >");
|
|
91 |
if ( iStatus != KErrNone )
|
|
92 |
{
|
|
93 |
//error code is ignored, as CPeriodic.
|
|
94 |
return;
|
|
95 |
}
|
|
96 |
StartWaitingIdleL();
|
|
97 |
}
|
|
98 |
|
|
99 |
// -----------------------------------------------------------------------------
|
|
100 |
// CTeleWaitingIdle::StartWaitingIdle
|
|
101 |
// (other items were commented in a header).
|
|
102 |
// -----------------------------------------------------------------------------
|
|
103 |
//
|
|
104 |
void CTeleWaitingIdle::StartWaitingIdleL()
|
|
105 |
{
|
|
106 |
// Phone_PRINT("WI.StartWaitingIdle >");
|
|
107 |
TInt state(0);
|
|
108 |
|
|
109 |
User::LeaveIfError(
|
|
110 |
iProperty.Get(
|
|
111 |
KPSUidStartup,
|
|
112 |
KPSIdlePhase1Ok,
|
|
113 |
state ) );
|
|
114 |
|
|
115 |
// Phone_PRINTF("CTeleWaitingIdle::After - state = %d >",state);
|
|
116 |
if ( IsActive() )
|
|
117 |
{
|
|
118 |
Cancel();
|
|
119 |
}
|
|
120 |
|
|
121 |
if ( state == EIdlePhase1Ok )
|
|
122 |
{
|
|
123 |
// Phone_PRINT("WI.StartWaitingIdle - RecoverAllNow");
|
|
124 |
iRecoverySystem.RecoverAllNow();
|
|
125 |
}
|
|
126 |
else
|
|
127 |
{
|
|
128 |
User::LeaveIfError(
|
|
129 |
iProperty.Attach(
|
|
130 |
KPSUidStartup,
|
|
131 |
KPSIdlePhase1Ok ) );
|
|
132 |
|
|
133 |
if ( !IsActive() )
|
|
134 |
{
|
|
135 |
iProperty.Subscribe( iStatus );
|
|
136 |
SetActive();
|
|
137 |
}
|
|
138 |
}
|
|
139 |
}
|
|
140 |
|
|
141 |
// End of File
|