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