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 info listener.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef C_AINETWORKINFOLISTENER_H
|
|
20 |
#define C_AINETWORKINFOLISTENER_H
|
|
21 |
|
|
22 |
// System includes
|
|
23 |
#include <e32base.h>
|
|
24 |
#include <NWHandlingEngine.h>
|
|
25 |
|
|
26 |
// User includes
|
|
27 |
|
|
28 |
// Forward declarations
|
|
29 |
class MAiNetworkInfoObserver;
|
|
30 |
class CNWSession;
|
|
31 |
|
|
32 |
|
|
33 |
/**
|
|
34 |
* @ingroup group_devicestatusplugin
|
|
35 |
*
|
|
36 |
* Network info listener.
|
|
37 |
*
|
|
38 |
* Client can use this object to listen network info changes. Client must implement
|
|
39 |
* MAiNetworkInfoObserver interface to retrieve network info change events.
|
|
40 |
*
|
|
41 |
* @since S60 3.2
|
|
42 |
*/
|
|
43 |
NONSHARABLE_CLASS( CAiNetworkInfoListener ) : public CBase,
|
|
44 |
public MNWMessageObserver
|
|
45 |
{
|
|
46 |
public:
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Get pointer to network info listener.
|
|
50 |
* When this is called first time, object is created, later calls
|
|
51 |
* gets pointer to previously created object.
|
|
52 |
*
|
|
53 |
* @since S60 3.2
|
|
54 |
* @return pointer to network info listener.
|
|
55 |
*/
|
|
56 |
static CAiNetworkInfoListener* InstanceL();
|
|
57 |
|
|
58 |
/**
|
|
59 |
* Release network info listener.
|
|
60 |
* This must be called when client doesn't listen network info
|
|
61 |
* changes anymore. When all of the listener instances are released,
|
|
62 |
* the object is destroyed. After client calls this method, the pointer
|
|
63 |
* returned by InstanceL must not be used anymore.
|
|
64 |
*
|
|
65 |
* @since S60 3.2
|
|
66 |
* @param ?arg1
|
|
67 |
* @param ?arg2
|
|
68 |
* @return
|
|
69 |
*/
|
|
70 |
void Release();
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Add network info observer.
|
|
74 |
*
|
|
75 |
* @since S60 3.2
|
|
76 |
* @param aObserver is interface which is used to inform network info changes.
|
|
77 |
*/
|
|
78 |
void AddObserverL( MAiNetworkInfoObserver& aObserver );
|
|
79 |
|
|
80 |
/**
|
|
81 |
* Remove network info observer.
|
|
82 |
*
|
|
83 |
* @since S60 3.2
|
|
84 |
* @param aObserver must be exactly same object as was given to AddObserverL call.
|
|
85 |
*/
|
|
86 |
void RemoveObserver( MAiNetworkInfoObserver& aObserver );
|
|
87 |
|
|
88 |
/**
|
|
89 |
* Get cached network info structure.
|
|
90 |
* When network info changes, it is stored in this listener, client can use this
|
|
91 |
* method to receive the latest network info.
|
|
92 |
*
|
|
93 |
* @since S60 3.2
|
|
94 |
* @return latest network info structure.
|
|
95 |
*/
|
|
96 |
const TNWInfo& NetworkInfo() const;
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Is the operator indicator allowed to be shown.
|
|
100 |
*
|
|
101 |
* @since S60 v3.2
|
|
102 |
* @return ETrue if the indicator can be shown.
|
|
103 |
*/
|
|
104 |
TBool IsOperatorIndicatorAllowed() const;
|
|
105 |
|
|
106 |
/**
|
|
107 |
* Client can use this method to check if certain network message has been already
|
|
108 |
* received.
|
|
109 |
*
|
|
110 |
* @since S60 3.2
|
|
111 |
* @param aMessage is type of the message.
|
|
112 |
* @return ETrue if the message has been received.
|
|
113 |
*/
|
|
114 |
TBool MessageReceived( MNWMessageObserver::TNWMessages aMessage );
|
|
115 |
|
|
116 |
/**
|
|
117 |
* Check if it's allowed to show operator indicator.
|
|
118 |
* Number of rules control operator indicator visibility.
|
|
119 |
* Parameter aMessage is used for fulfilling these rules - it can have
|
|
120 |
* various values so this method is called many times. The sum of the
|
|
121 |
* calls (and thus sum of different aMessage values) defines whether
|
|
122 |
* rules are fulfilled and indicator is shown.
|
|
123 |
* @param aMessage Network message
|
|
124 |
* @return ETrue if rules are not fulfilled and indicator should
|
|
125 |
* not be shown.
|
|
126 |
*/
|
|
127 |
TBool NotAllowedToDisplayOperatorIndicator( const TNWMessages aMessage );
|
|
128 |
|
|
129 |
/**
|
|
130 |
* Check if network info has been changed.
|
|
131 |
* @param aMessage Network message
|
|
132 |
* @return ETrue if network info has changed since last check.
|
|
133 |
*/
|
|
134 |
TBool HasNetworkInfoChanged( const TNWMessages aMessage );
|
|
135 |
|
|
136 |
|
|
137 |
// from base class MNWMessageObserver
|
|
138 |
|
|
139 |
/**
|
|
140 |
* From MNWMessageObserver.
|
|
141 |
* Called by network handling engine when network info changes.
|
|
142 |
*
|
|
143 |
* @since S60 3.2
|
|
144 |
* @param aMessage is type of the change.
|
|
145 |
*/
|
|
146 |
void HandleNetworkMessage( const TNWMessages aMessage );
|
|
147 |
|
|
148 |
/**
|
|
149 |
* From MNWMessageObserver.
|
|
150 |
* Called fi network handling engine fails.
|
|
151 |
*
|
|
152 |
* @since S60 3.2
|
|
153 |
* @param aOperation is failed operation.
|
|
154 |
* @param aErrorCode is fail reason.
|
|
155 |
*/
|
|
156 |
void HandleNetworkError( const TNWOperation aOperation, TInt aErrorCode );
|
|
157 |
|
|
158 |
private:
|
|
159 |
|
|
160 |
CAiNetworkInfoListener();
|
|
161 |
|
|
162 |
void ConstructL();
|
|
163 |
|
|
164 |
~CAiNetworkInfoListener();
|
|
165 |
|
|
166 |
/**
|
|
167 |
* Increase access count.
|
|
168 |
*/
|
|
169 |
TInt IncAccessCount();
|
|
170 |
|
|
171 |
/**
|
|
172 |
* Decrease access count, when this goes to zero, object is deleted.
|
|
173 |
*/
|
|
174 |
TInt DecAccessCount();
|
|
175 |
|
|
176 |
private: // data
|
|
177 |
|
|
178 |
/**
|
|
179 |
* Array of observers.
|
|
180 |
* Not own.
|
|
181 |
*/
|
|
182 |
RArray<MAiNetworkInfoObserver*> iObservers;
|
|
183 |
|
|
184 |
/**
|
|
185 |
* Session to network handling engine.
|
|
186 |
* Own.
|
|
187 |
*/
|
|
188 |
CNWSession* iSession;
|
|
189 |
|
|
190 |
/**
|
|
191 |
* Cached network info structure.
|
|
192 |
*/
|
|
193 |
TNWInfo iInfo;
|
|
194 |
|
|
195 |
/**
|
|
196 |
* Previous network information.
|
|
197 |
*/
|
|
198 |
TNWInfo iOldInfo;
|
|
199 |
|
|
200 |
/**
|
|
201 |
* Message cache. There is only one instance of one type of message.
|
|
202 |
* Own.
|
|
203 |
*/
|
|
204 |
CArrayFixFlat<MNWMessageObserver::TNWMessages>* iMessageCache;
|
|
205 |
|
|
206 |
/**
|
|
207 |
* Sorting rule.
|
|
208 |
*/
|
|
209 |
TKeyArrayFix iKeyProperties;
|
|
210 |
|
|
211 |
/**
|
|
212 |
* Access count.
|
|
213 |
*/
|
|
214 |
TInt iAccessCount;
|
|
215 |
|
|
216 |
/**
|
|
217 |
* Network related message flags
|
|
218 |
*/
|
|
219 |
enum TNetInfoFlags
|
|
220 |
{
|
|
221 |
ENetworkProviderNameReceived = 0x00000001,
|
|
222 |
ENetworkProviderNameOk = 0x00000002,
|
|
223 |
EServiceProviderNameReceived = 0x00000004,
|
|
224 |
EServiceProviderNameOk = 0x00000008,
|
|
225 |
ERegistrationStatusReceived = 0x00000010,
|
|
226 |
ENetworkInfoChangeReceived = 0x00000020,
|
|
227 |
EProgrammableOperatorInfoReceived = 0x00000040,
|
|
228 |
EProgrammableOperatorInfoReceivedOk = 0x00000080,
|
|
229 |
ECSRegistrationNotOk = 0x00000100
|
|
230 |
};
|
|
231 |
|
|
232 |
/**
|
|
233 |
* Subset of sum of TNetInfoFlags.
|
|
234 |
*/
|
|
235 |
TUint iReceivedMessageFlags;
|
|
236 |
|
|
237 |
/**
|
|
238 |
* Subset of sum of old TNetInfoFlags.
|
|
239 |
*/
|
|
240 |
TUint iOldReceivedMessageFlags;
|
|
241 |
|
|
242 |
/**
|
|
243 |
* Is the operator indicator allowed to show
|
|
244 |
*/
|
|
245 |
TBool iShowOpInd;
|
|
246 |
};
|
|
247 |
|
|
248 |
|
|
249 |
|
|
250 |
#endif // C_AINETWORKINFOLISTENER_H
|