114
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2006 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: Network status publisher
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "ainwspublisher.h"
|
|
20 |
#include <aicontentobserver.h>
|
|
21 |
#include "ainetworkinfolistener.h"
|
|
22 |
|
|
23 |
#include <activeidle2domainpskeys.h>
|
|
24 |
#include <e32property.h>
|
|
25 |
#include <centralrepository.h>
|
|
26 |
#include <ProfileEngineSDKCRKeys.h>
|
|
27 |
#include <BTSapDomainPSKeys.h>
|
|
28 |
|
|
29 |
#include "debug.h"
|
|
30 |
|
|
31 |
// Offline profile, from ProfileEngineSDKCRKeys.h
|
|
32 |
const TInt KOfflineProfileId = 5;
|
|
33 |
|
|
34 |
// ======== MEMBER FUNCTIONS ========
|
|
35 |
|
|
36 |
CAiNwsPublisher::CAiNwsPublisher()
|
|
37 |
{
|
|
38 |
iRegistered = ETrue;
|
|
39 |
}
|
|
40 |
|
|
41 |
|
|
42 |
void CAiNwsPublisher::ConstructL()
|
|
43 |
{
|
|
44 |
iListener = CAiNetworkInfoListener::InstanceL();
|
|
45 |
iProfileApi = CRepository::NewL( KCRUidProfileEngine );
|
|
46 |
}
|
|
47 |
|
|
48 |
CAiNwsPublisher* CAiNwsPublisher::NewL()
|
|
49 |
{
|
|
50 |
CAiNwsPublisher* self = new( ELeave ) CAiNwsPublisher;
|
|
51 |
CleanupStack::PushL( self );
|
|
52 |
self->ConstructL();
|
|
53 |
CleanupStack::Pop( self );
|
|
54 |
return self;
|
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
CAiNwsPublisher::~CAiNwsPublisher()
|
|
59 |
{
|
|
60 |
if( iListener )
|
|
61 |
{
|
|
62 |
iListener->RemoveObserver( *this );
|
|
63 |
iListener->Release();
|
|
64 |
}
|
|
65 |
delete iProfileApi;
|
|
66 |
}
|
|
67 |
|
|
68 |
|
|
69 |
void CAiNwsPublisher::ResumeL()
|
|
70 |
{
|
|
71 |
iListener->AddObserverL( *this );
|
|
72 |
}
|
|
73 |
|
|
74 |
|
|
75 |
void CAiNwsPublisher::Subscribe( MAiContentObserver& aObserver,
|
|
76 |
CHsContentPublisher& aExtension,
|
|
77 |
MAiPublishPrioritizer& /*aPrioritizer*/,
|
|
78 |
MAiPublisherBroadcaster& /*aBroadcaster*/ )
|
|
79 |
{
|
|
80 |
iContentObserver = &aObserver;
|
|
81 |
iExtension = &aExtension;
|
|
82 |
}
|
|
83 |
|
|
84 |
|
|
85 |
void CAiNwsPublisher::RefreshL( TBool /*aClean*/ )
|
|
86 |
{
|
|
87 |
HandleStateChange( iListener->NetworkInfo() );
|
|
88 |
}
|
|
89 |
|
|
90 |
TBool CAiNwsPublisher::RefreshL( TInt aContentId, TBool aClean )
|
|
91 |
{
|
|
92 |
if( aContentId == EAiDeviceStatusContentNWStatus )
|
|
93 |
{
|
|
94 |
RefreshL( aClean );
|
|
95 |
return ETrue;
|
|
96 |
}
|
|
97 |
|
|
98 |
return EFalse;
|
|
99 |
}
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
void CAiNwsPublisher::HandleNetworkInfoChange(
|
|
104 |
const MNWMessageObserver::TNWMessages& /*aMessage*/,
|
|
105 |
const TNWInfo& aInfo,
|
|
106 |
const TBool /*aShowOpInd*/ )
|
|
107 |
{
|
|
108 |
HandleStateChange( aInfo );
|
|
109 |
}
|
|
110 |
|
|
111 |
void CAiNwsPublisher::HandleStateChange( const TNWInfo& aInfo )
|
|
112 |
{
|
|
113 |
switch( aInfo.iRegistrationStatus )
|
|
114 |
{
|
|
115 |
case ENWNotRegisteredNoService:
|
|
116 |
// Fall-through
|
|
117 |
case ENWNotRegisteredEmergencyOnly:
|
|
118 |
// Fall-through
|
|
119 |
case ENWNotRegisteredSearching:
|
|
120 |
// Fall-through
|
|
121 |
case ENWRegistrationDenied:
|
|
122 |
HandleNetworkLost( aInfo.iSelectionSetting );
|
|
123 |
break;
|
|
124 |
|
|
125 |
case ENWRegisteredBusy:
|
|
126 |
// Fall-through
|
|
127 |
case ENWRegisteredOnHomeNetwork:
|
|
128 |
// Fall-through
|
|
129 |
case ENWRegisteredRoaming:
|
|
130 |
HandleNetworkFound();
|
|
131 |
break;
|
|
132 |
|
|
133 |
case ENWRegistrationUnknown:
|
|
134 |
// Take no action
|
|
135 |
default:
|
|
136 |
break;
|
|
137 |
}
|
|
138 |
}
|
|
139 |
|
|
140 |
void CAiNwsPublisher::HandleNetworkFound()
|
|
141 |
{
|
|
142 |
__PRINTS( "XAI: Network found, clean state" );
|
|
143 |
iRegistered = ETrue;
|
|
144 |
if ( iContentObserver && iExtension )
|
|
145 |
{
|
|
146 |
iContentObserver->Clean( *iExtension, EAiDeviceStatusContentNWStatus, 0 );
|
|
147 |
}
|
|
148 |
}
|
|
149 |
|
|
150 |
void CAiNwsPublisher::HandleNetworkLost( const TNWNetworkSelectionSetting &aSelectionSetting )
|
|
151 |
{
|
|
152 |
if( aSelectionSetting == ENWNetworkSelectionManual )
|
|
153 |
{
|
|
154 |
// See if we were registered before
|
|
155 |
if( iRegistered )
|
|
156 |
{
|
|
157 |
iRegistered = EFalse;
|
|
158 |
|
|
159 |
if( !IsOffLineMode() &&
|
|
160 |
!IsBluetoothSAPConnected() &&
|
|
161 |
iContentObserver &&
|
|
162 |
iExtension )
|
|
163 |
{
|
|
164 |
__PRINTS( "XAI: Network lost, publish state" );
|
|
165 |
iContentObserver->Publish( *iExtension,
|
|
166 |
EAiDeviceStatusContentNWStatus,
|
|
167 |
EAiDeviceStatusResourceNWLost,
|
|
168 |
0 );
|
|
169 |
}
|
|
170 |
}
|
|
171 |
}
|
|
172 |
}
|
|
173 |
|
|
174 |
TBool CAiNwsPublisher::IsOffLineMode() const
|
|
175 |
{
|
|
176 |
TInt profileId;
|
|
177 |
TInt err = iProfileApi->Get( KProEngActiveProfile, profileId );
|
|
178 |
return profileId == KOfflineProfileId && err == KErrNone;
|
|
179 |
}
|
|
180 |
|
|
181 |
TBool CAiNwsPublisher::IsBluetoothSAPConnected() const
|
|
182 |
{
|
|
183 |
TInt btSapState( EBTSapNotConnected );
|
|
184 |
TInt err = RProperty::Get( KPSUidBluetoothSapConnectionState,
|
|
185 |
KBTSapConnectionState,
|
|
186 |
btSapState );
|
|
187 |
return btSapState != EBTSapNotConnected && err == KErrNone;
|
|
188 |
}
|