56
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: Class definition of cell change handler.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "lbtcellchangehandler.h"
|
|
20 |
#include "lbtlogger.h"
|
|
21 |
|
|
22 |
// ======== MEMBER FUNCTIONS ========
|
|
23 |
|
|
24 |
// --------------------------------------------------------------------------
|
|
25 |
// CLbtCellChangeHandler::NewL
|
|
26 |
// CLbtCellChangeHandler instantiation method
|
|
27 |
// --------------------------------------------------------------------------
|
|
28 |
//
|
|
29 |
CLbtCellChangeHandler* CLbtCellChangeHandler::NewL(RMobilePhone& aMPhone)
|
|
30 |
{
|
|
31 |
FUNC_ENTER("CLbtCellChangeHandler::NewL");
|
|
32 |
CLbtCellChangeHandler* self = new (ELeave) CLbtCellChangeHandler(aMPhone);
|
|
33 |
CleanupStack::PushL(self);
|
|
34 |
self->ConstructL();
|
|
35 |
CleanupStack::Pop();
|
|
36 |
return self;
|
|
37 |
}
|
|
38 |
|
|
39 |
// -----------------------------------------------------------------------------
|
|
40 |
// CLbtCellChangeHandler::CLbtCellChangeHandler
|
|
41 |
//
|
|
42 |
// -----------------------------------------------------------------------------
|
|
43 |
//
|
|
44 |
CLbtCellChangeHandler::CLbtCellChangeHandler(RMobilePhone& aMPhone):
|
|
45 |
CActive(EPriorityStandard), iMPhone(aMPhone),
|
|
46 |
iCommandId(-1), iNwInfo(), iNwInfoPckg(iNwInfo), iLocArea()
|
|
47 |
{
|
|
48 |
CActiveScheduler::Add(this);
|
|
49 |
}
|
|
50 |
|
|
51 |
// -----------------------------------------------------------------------------
|
|
52 |
// CLbtCellChangeHandler::~CLbtCellChangeHandler
|
|
53 |
//
|
|
54 |
// -----------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CLbtCellChangeHandler::~CLbtCellChangeHandler()
|
|
57 |
{
|
|
58 |
FUNC_ENTER("CLbtCellChangeHandler::~CLbtCellChangeHandler");
|
|
59 |
if (IsActive())
|
|
60 |
{
|
|
61 |
Cancel();
|
|
62 |
}
|
|
63 |
iObserverArray.Close();
|
|
64 |
}
|
|
65 |
|
|
66 |
|
|
67 |
// -----------------------------------------------------------------------------
|
|
68 |
// CLbtCellChangeHandler::ConstructL
|
|
69 |
//
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
void CLbtCellChangeHandler::ConstructL()
|
|
73 |
{
|
|
74 |
|
|
75 |
}
|
|
76 |
|
|
77 |
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
// CLbtCellChangeHandler::RunL
|
|
80 |
//
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
void CLbtCellChangeHandler::RunL()
|
|
84 |
{
|
|
85 |
FUNC_ENTER("CLbtCellChangeHandler::RunL");
|
|
86 |
if( iStatus.Int() == KErrNone )
|
|
87 |
{
|
|
88 |
for( TInt i=0;i<iObserverArray.Count();i++ )
|
|
89 |
{
|
|
90 |
iObserverArray[i]->HandleCellChangeEvent( KErrNone, iNwInfo, iLocArea );
|
|
91 |
}
|
|
92 |
}
|
|
93 |
iLastStatusInfo = iStatus.Int();
|
|
94 |
|
|
95 |
if( !IsActive() )
|
|
96 |
{
|
|
97 |
iMPhone.NotifyCurrentNetworkChange( iStatus, iNwInfoPckg, iLocArea );
|
|
98 |
SetActive();
|
|
99 |
iCommandId = EMobilePhoneNotifyCurrentNetworkChange;
|
|
100 |
}
|
|
101 |
}
|
|
102 |
|
|
103 |
// -----------------------------------------------------------------------------
|
|
104 |
// CLbtCellChangeHandler::DoCancel
|
|
105 |
//
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
//
|
|
108 |
void CLbtCellChangeHandler::DoCancel()
|
|
109 |
{
|
|
110 |
FUNC_ENTER("CLbtCellChangeHandler::DoCancel");
|
|
111 |
iMPhone.CancelAsyncRequest( iCommandId );
|
|
112 |
}
|
|
113 |
|
|
114 |
// -----------------------------------------------------------------------------
|
|
115 |
// CLbtCellChangeHandler::GetNetworkInfo
|
|
116 |
//
|
|
117 |
// -----------------------------------------------------------------------------
|
|
118 |
//
|
|
119 |
void CLbtCellChangeHandler::GetNetworkInfo()
|
|
120 |
{
|
|
121 |
FUNC_ENTER("CLbtCellChangeHandler::GetNetworkInfo");
|
|
122 |
if(!IsActive())
|
|
123 |
{
|
|
124 |
iMPhone.GetCurrentNetwork( iStatus,iNwInfoPckg,iLocArea );
|
|
125 |
SetActive();
|
|
126 |
iCommandId = EMobilePhoneGetCurrentNetwork;
|
|
127 |
}
|
|
128 |
}
|
|
129 |
|
|
130 |
// -----------------------------------------------------------------------------
|
|
131 |
// CLbtCellChangeHandler::SetObserver
|
|
132 |
//
|
|
133 |
// -----------------------------------------------------------------------------
|
|
134 |
//
|
|
135 |
void CLbtCellChangeHandler::SetObserver( MCellChangeObserver* aObserver )
|
|
136 |
{
|
|
137 |
FUNC_ENTER("CLbtCellChangeHandler::SetObserver");
|
|
138 |
iObserverArray.Append( aObserver );
|
|
139 |
// If cell change handler already has cell information,update it to the observer
|
|
140 |
if( iLocArea.iCellId && iLastStatusInfo == KErrNone )
|
|
141 |
{
|
|
142 |
aObserver->HandleCellChangeEvent( iLastStatusInfo ,iNwInfo, iLocArea );
|
|
143 |
}
|
|
144 |
if( !IsActive() )
|
|
145 |
{
|
|
146 |
GetNetworkInfo();
|
|
147 |
}
|
|
148 |
}
|
|
149 |
|
|
150 |
// -----------------------------------------------------------------------------
|
|
151 |
// CLbtCellChangeHandler::Remove
|
|
152 |
//
|
|
153 |
// -----------------------------------------------------------------------------
|
|
154 |
//
|
|
155 |
void CLbtCellChangeHandler::Remove( MCellChangeObserver* aObserver )
|
|
156 |
{
|
|
157 |
FUNC_ENTER("CLbtCellChangeHandler::Remove");
|
|
158 |
if( iObserverArray.Count() )
|
|
159 |
{
|
|
160 |
TInt position = iObserverArray.Find( aObserver );
|
|
161 |
if( position != KErrNotFound )
|
|
162 |
{
|
|
163 |
iObserverArray.Remove( position );
|
|
164 |
if( !iObserverArray.Count() )
|
|
165 |
{
|
|
166 |
Cancel();
|
|
167 |
}
|
|
168 |
}
|
|
169 |
}
|
|
170 |
}
|
|
171 |
// End of File
|
|
172 |
|