29
|
1 |
/*
|
54
|
2 |
* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
|
29
|
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: AT NVRAM status change listener and notifier
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "DunAtNvramListen.h"
|
|
20 |
#include "DunDebug.h"
|
|
21 |
|
|
22 |
// ---------------------------------------------------------------------------
|
|
23 |
// Two-phased constructor.
|
|
24 |
// ---------------------------------------------------------------------------
|
|
25 |
//
|
|
26 |
CDunAtNvramListen* CDunAtNvramListen::NewL( RATExt* aAtCmdExt,
|
|
27 |
RATExtCommon* aAtCmdExtCommon )
|
|
28 |
{
|
|
29 |
CDunAtNvramListen* self = NewLC( aAtCmdExt, aAtCmdExtCommon );
|
|
30 |
CleanupStack::Pop( self );
|
|
31 |
return self;
|
|
32 |
}
|
|
33 |
|
|
34 |
// ---------------------------------------------------------------------------
|
|
35 |
// Two-phased constructor.
|
|
36 |
// ---------------------------------------------------------------------------
|
|
37 |
//
|
|
38 |
CDunAtNvramListen* CDunAtNvramListen::NewLC( RATExt* aAtCmdExt,
|
|
39 |
RATExtCommon* aAtCmdExtCommon )
|
|
40 |
{
|
|
41 |
CDunAtNvramListen* self = new (ELeave) CDunAtNvramListen(
|
|
42 |
aAtCmdExt,
|
|
43 |
aAtCmdExtCommon );
|
|
44 |
CleanupStack::PushL( self );
|
|
45 |
self->ConstructL();
|
|
46 |
return self;
|
|
47 |
}
|
|
48 |
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
// Destructor.
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
CDunAtNvramListen::~CDunAtNvramListen()
|
|
54 |
{
|
|
55 |
FTRACE(FPrint( _L("CDunAtNvramListen::~CDunAtNvramListen()") ));
|
|
56 |
ResetData();
|
|
57 |
FTRACE(FPrint( _L("CDunAtNvramListen::~CDunAtNvramListen() complete") ));
|
|
58 |
}
|
|
59 |
|
|
60 |
// ---------------------------------------------------------------------------
|
|
61 |
// Resets data to initial values
|
|
62 |
// ---------------------------------------------------------------------------
|
|
63 |
//
|
|
64 |
void CDunAtNvramListen::ResetData()
|
|
65 |
{
|
|
66 |
FTRACE(FPrint( _L("CDunAtNvramListen::ResetData()") ));
|
|
67 |
// APIs affecting this:
|
|
68 |
// IssueRequest()
|
|
69 |
Stop();
|
|
70 |
// Internal
|
|
71 |
Initialize();
|
|
72 |
FTRACE(FPrint( _L("CDunAtNvramListen::ResetData() complete") ));
|
|
73 |
}
|
|
74 |
|
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
// Starts waiting for NVRAM status changes
|
|
77 |
// ---------------------------------------------------------------------------
|
|
78 |
//
|
|
79 |
TInt CDunAtNvramListen::IssueRequest()
|
|
80 |
{
|
|
81 |
FTRACE(FPrint( _L("CDunAtNvramListen::IssueRequest()") ));
|
54
|
82 |
if ( IsActive() )
|
29
|
83 |
{
|
|
84 |
FTRACE(FPrint( _L("CDunAtNvramListen::IssueRequest() (not ready) complete") ));
|
|
85 |
return KErrNotReady;
|
|
86 |
}
|
|
87 |
if ( !iStarted )
|
|
88 |
{
|
|
89 |
iAtCmdExtCommon->GetNvramStatus( iNvramBuffer );
|
|
90 |
iAtCmdExt->BroadcastNvramStatusChange( iNvramBuffer );
|
|
91 |
iStarted = ETrue;
|
|
92 |
}
|
|
93 |
iAtCmdExtCommon->ReceiveNvramStatusChange( iStatus, iNvramBuffer );
|
|
94 |
SetActive();
|
|
95 |
FTRACE(FPrint( _L("CDunAtNvramListen::IssueRequest() complete") ));
|
|
96 |
return KErrNone;
|
|
97 |
}
|
|
98 |
|
|
99 |
// ---------------------------------------------------------------------------
|
|
100 |
// Stops waiting for NVRAM status changes
|
|
101 |
// ---------------------------------------------------------------------------
|
|
102 |
//
|
54
|
103 |
void CDunAtNvramListen::Stop()
|
29
|
104 |
{
|
|
105 |
FTRACE(FPrint( _L("CDunAtNvramListen::Stop()") ));
|
|
106 |
Cancel();
|
|
107 |
FTRACE(FPrint( _L("CDunAtNvramListen::Stop() complete") ));
|
|
108 |
// Note: Don't mark iStarted to EFalse here!
|
|
109 |
}
|
|
110 |
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
// CDunAtNvramListen::CDunAtNvramListen
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
//
|
|
115 |
CDunAtNvramListen::CDunAtNvramListen( RATExt* aAtCmdExt,
|
|
116 |
RATExtCommon* aAtCmdExtCommon ) :
|
|
117 |
CActive( EPriorityHigh ),
|
|
118 |
iAtCmdExt( aAtCmdExt ),
|
|
119 |
iAtCmdExtCommon( aAtCmdExtCommon )
|
|
120 |
{
|
|
121 |
Initialize();
|
|
122 |
}
|
|
123 |
|
|
124 |
// ---------------------------------------------------------------------------
|
|
125 |
// CDunAtNvramListen::ConstructL
|
|
126 |
// ---------------------------------------------------------------------------
|
|
127 |
//
|
|
128 |
void CDunAtNvramListen::ConstructL()
|
|
129 |
{
|
|
130 |
FTRACE(FPrint( _L("CDunAtNvramListen::ConstructL()") ));
|
|
131 |
if ( !iAtCmdExt || !iAtCmdExtCommon )
|
|
132 |
{
|
|
133 |
User::Leave( KErrGeneral );
|
|
134 |
}
|
|
135 |
CActiveScheduler::Add( this );
|
|
136 |
FTRACE(FPrint( _L("CDunAtNvramListen::ConstructL() complete") ));
|
|
137 |
}
|
|
138 |
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
// Initializes this class
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
void CDunAtNvramListen::Initialize()
|
|
144 |
{
|
|
145 |
// Don't initialize iAtCmdExt here (it is set through NewL)
|
|
146 |
// Don't initialize iAtCmdExtCommon here (it is set through NewL)
|
|
147 |
iStarted = EFalse;
|
|
148 |
}
|
|
149 |
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
// From class CActive.
|
|
152 |
// Gets called when NVRAM has changed
|
|
153 |
// ---------------------------------------------------------------------------
|
|
154 |
//
|
|
155 |
void CDunAtNvramListen::RunL()
|
|
156 |
{
|
|
157 |
FTRACE(FPrint( _L("CDunAtNvramListen::RunL()") ));
|
|
158 |
TInt retTemp = iStatus.Int();
|
|
159 |
if ( retTemp != KErrNone )
|
|
160 |
{
|
|
161 |
FTRACE(FPrint( _L("CDunAtNvramListen::RunL() (ERROR) complete (%d)"), retTemp ));
|
|
162 |
return;
|
|
163 |
}
|
|
164 |
iAtCmdExt->BroadcastNvramStatusChange( iNvramBuffer );
|
|
165 |
IssueRequest();
|
|
166 |
FTRACE(FPrint( _L("CDunAtNvramListen::RunL() complete") ));
|
|
167 |
}
|
|
168 |
|
|
169 |
// ---------------------------------------------------------------------------
|
|
170 |
// From class CActive.
|
|
171 |
// Gets called on cancel
|
|
172 |
// ---------------------------------------------------------------------------
|
|
173 |
//
|
|
174 |
void CDunAtNvramListen::DoCancel()
|
|
175 |
{
|
|
176 |
FTRACE(FPrint( _L("CDunAtNvramListen::DoCancel()") ));
|
54
|
177 |
iAtCmdExtCommon->CancelReceiveNvramStatusChange();
|
29
|
178 |
FTRACE(FPrint( _L("CDunAtNvramListen::DoCancel() complete") ));
|
|
179 |
}
|