author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:55:16 +0300 | |
branch | RCL_3 |
changeset 31 | 8baec10861af |
parent 30 | a5a39a295112 |
permissions | -rw-r--r-- |
30 | 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 |
{ |
|
31
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
44 |
__PRINTS( "XAI: CAiNwsPublisher > ConstructL" ); |
30 | 45 |
iListener = CAiNetworkInfoListener::InstanceL(); |
46 |
iProfileApi = CRepository::NewL( KCRUidProfileEngine ); |
|
47 |
} |
|
48 |
||
49 |
CAiNwsPublisher* CAiNwsPublisher::NewL() |
|
50 |
{ |
|
51 |
CAiNwsPublisher* self = new( ELeave ) CAiNwsPublisher; |
|
52 |
CleanupStack::PushL( self ); |
|
53 |
self->ConstructL(); |
|
54 |
CleanupStack::Pop( self ); |
|
55 |
return self; |
|
56 |
} |
|
57 |
||
58 |
||
59 |
CAiNwsPublisher::~CAiNwsPublisher() |
|
60 |
{ |
|
31
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
61 |
__PRINTS( "XAI: CAiNwsPublisher > ~CAiNwsPublisher" ); |
30 | 62 |
if( iListener ) |
63 |
{ |
|
64 |
iListener->RemoveObserver( *this ); |
|
65 |
iListener->Release(); |
|
66 |
} |
|
67 |
delete iProfileApi; |
|
68 |
} |
|
69 |
||
70 |
||
71 |
void CAiNwsPublisher::ResumeL() |
|
72 |
{ |
|
31
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
73 |
__PRINTS( "XAI: CAiNwsPublisher > ResumeL" ); |
30 | 74 |
iListener->AddObserverL( *this ); |
75 |
} |
|
76 |
||
77 |
||
78 |
void CAiNwsPublisher::Subscribe( MAiContentObserver& aObserver, |
|
79 |
CHsContentPublisher& aExtension, |
|
80 |
MAiPublishPrioritizer& /*aPrioritizer*/, |
|
81 |
MAiPublisherBroadcaster& /*aBroadcaster*/ ) |
|
82 |
{ |
|
31
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
83 |
__PRINTS( "XAI: CAiNwsPublisher > Subscribe" ); |
30 | 84 |
iContentObserver = &aObserver; |
85 |
iExtension = &aExtension; |
|
86 |
} |
|
87 |
||
88 |
||
89 |
void CAiNwsPublisher::RefreshL( TBool /*aClean*/ ) |
|
90 |
{ |
|
91 |
HandleStateChange( iListener->NetworkInfo() ); |
|
92 |
} |
|
93 |
||
94 |
TBool CAiNwsPublisher::RefreshL( TInt aContentId, TBool aClean ) |
|
95 |
{ |
|
31
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
96 |
__PRINTS( "XAI: CAiNwsPublisher::RefreshL" ); |
30 | 97 |
if( aContentId == EAiDeviceStatusContentNWStatus ) |
98 |
{ |
|
31
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
99 |
__PRINTS( "XAI: content EAiDeviceStatusContentNWStatus" ); |
30 | 100 |
RefreshL( aClean ); |
101 |
return ETrue; |
|
102 |
} |
|
103 |
||
104 |
return EFalse; |
|
105 |
} |
|
106 |
||
107 |
void CAiNwsPublisher::HandleNetworkInfoChange( |
|
108 |
const MNWMessageObserver::TNWMessages& /*aMessage*/, |
|
109 |
const TNWInfo& aInfo, |
|
110 |
const TBool /*aShowOpInd*/ ) |
|
111 |
{ |
|
31
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
112 |
__PRINTS( "XAI: CAiNwsPublisher::HandleNetworkInfoChange" ); |
30 | 113 |
HandleStateChange( aInfo ); |
114 |
} |
|
115 |
||
116 |
void CAiNwsPublisher::HandleStateChange( const TNWInfo& aInfo ) |
|
117 |
{ |
|
118 |
switch( aInfo.iRegistrationStatus ) |
|
119 |
{ |
|
120 |
case ENWNotRegisteredNoService: |
|
121 |
// Fall-through |
|
122 |
case ENWNotRegisteredEmergencyOnly: |
|
123 |
// Fall-through |
|
124 |
case ENWNotRegisteredSearching: |
|
125 |
// Fall-through |
|
126 |
case ENWRegistrationDenied: |
|
127 |
HandleNetworkLost( aInfo.iSelectionSetting ); |
|
128 |
break; |
|
129 |
||
130 |
case ENWRegisteredBusy: |
|
131 |
// Fall-through |
|
132 |
case ENWRegisteredOnHomeNetwork: |
|
133 |
// Fall-through |
|
134 |
case ENWRegisteredRoaming: |
|
135 |
HandleNetworkFound(); |
|
136 |
break; |
|
137 |
||
138 |
case ENWRegistrationUnknown: |
|
139 |
// Take no action |
|
140 |
default: |
|
141 |
break; |
|
142 |
} |
|
143 |
} |
|
144 |
||
145 |
void CAiNwsPublisher::HandleNetworkFound() |
|
146 |
{ |
|
31
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
147 |
__PRINTS( "XAI: Network found" ); |
30 | 148 |
iRegistered = ETrue; |
149 |
if ( iContentObserver && iExtension ) |
|
150 |
{ |
|
31
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
151 |
__PRINTS( "XAI: Network found, clean state" ); |
30 | 152 |
iContentObserver->Clean( *iExtension, EAiDeviceStatusContentNWStatus, 0 ); |
153 |
} |
|
154 |
} |
|
155 |
||
156 |
void CAiNwsPublisher::HandleNetworkLost( const TNWNetworkSelectionSetting &aSelectionSetting ) |
|
157 |
{ |
|
31
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
158 |
__PRINTS( "XAI: Network lost" ); |
30 | 159 |
if( aSelectionSetting == ENWNetworkSelectionManual ) |
160 |
{ |
|
161 |
// See if we were registered before |
|
162 |
if( iRegistered ) |
|
163 |
{ |
|
164 |
iRegistered = EFalse; |
|
165 |
||
166 |
if( !IsOffLineMode() && |
|
167 |
!IsBluetoothSAPConnected() && |
|
168 |
iContentObserver && |
|
169 |
iExtension ) |
|
170 |
{ |
|
171 |
__PRINTS( "XAI: Network lost, publish state" ); |
|
172 |
iContentObserver->Publish( *iExtension, |
|
173 |
EAiDeviceStatusContentNWStatus, |
|
174 |
EAiDeviceStatusResourceNWLost, |
|
175 |
0 ); |
|
176 |
} |
|
177 |
} |
|
178 |
} |
|
179 |
} |
|
180 |
||
181 |
TBool CAiNwsPublisher::IsOffLineMode() const |
|
182 |
{ |
|
183 |
TInt profileId; |
|
184 |
TInt err = iProfileApi->Get( KProEngActiveProfile, profileId ); |
|
185 |
return profileId == KOfflineProfileId && err == KErrNone; |
|
186 |
} |
|
187 |
||
188 |
TBool CAiNwsPublisher::IsBluetoothSAPConnected() const |
|
189 |
{ |
|
190 |
TInt btSapState( EBTSapNotConnected ); |
|
191 |
TInt err = RProperty::Get( KPSUidBluetoothSapConnectionState, |
|
192 |
KBTSapConnectionState, |
|
193 |
btSapState ); |
|
194 |
return btSapState != EBTSapNotConnected && err == KErrNone; |
|
195 |
} |