|
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 the License "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32std.h> |
|
21 #include <e32cmn.h> |
|
22 #include <E32HAL.H> |
|
23 #include <wlaninternalpskeys.h> // For WLAN state checking |
|
24 |
|
25 |
|
26 #include "ApiProvider.h" |
|
27 #include "WlanObserver.h" |
|
28 #include "Display.h" |
|
29 |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CWlanObserver::CWlanObserver |
|
35 // C++ default constructor can NOT contain any code, that |
|
36 // might leave. |
|
37 // ----------------------------------------------------------------------------- |
|
38 CWlanObserver::CWlanObserver(MApiProvider& aApiProvider) |
|
39 : CActive( EPriorityStandard ), |
|
40 iApiProvider( aApiProvider ) |
|
41 { |
|
42 CActiveScheduler::Add( this ); |
|
43 iWlanProperty.Attach( KPSUidWlan, KPSWlanIndicator ); |
|
44 iWlanProperty.Subscribe( iStatus ); |
|
45 SetActive(); |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CWlanObserver::~CWlanObserver() |
|
50 // Destructor |
|
51 // ----------------------------------------------------------------------------- |
|
52 CWlanObserver::~CWlanObserver() |
|
53 { |
|
54 Cancel(); |
|
55 iWlanProperty.Close(); |
|
56 } |
|
57 |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CWlanObserver::GetCurrentState |
|
61 // |
|
62 // Retrieves current state of wireless lan connection |
|
63 // @param aWlanStateValue reference to current Wlan state value which is updated here |
|
64 // @return: EFalse if error condition (ignore aWlanStateValue in this case) |
|
65 // Etrue if no error (get updated value from aWlanStateValue) |
|
66 // ----------------------------------------------------------------------------- |
|
67 TBool CWlanObserver::GetCurrentState(TInt &aWlanStateValue) |
|
68 { |
|
69 TInt value; |
|
70 TInt errorval = iWlanProperty.Get( value ); |
|
71 if (!errorval ) |
|
72 { |
|
73 aWlanStateValue = value; |
|
74 return( ETrue ); |
|
75 } |
|
76 else |
|
77 { |
|
78 return( EFalse ); |
|
79 } |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CWlanObserver::RunL |
|
84 // ----------------------------------------------------------------------------- |
|
85 void CWlanObserver::RunL() |
|
86 { |
|
87 if( iStatus==KErrNone ) |
|
88 { |
|
89 iWlanProperty.Subscribe( iStatus ); |
|
90 SetActive(); |
|
91 |
|
92 TInt value; |
|
93 if ( GetCurrentState(value) ) |
|
94 { |
|
95 iApiProvider.Display().UpdateWlanIndicator( value ); |
|
96 } |
|
97 } |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CWlanObserver::RunError |
|
102 // ----------------------------------------------------------------------------- |
|
103 TInt CWlanObserver::RunError( TInt /*aError*/ ) |
|
104 { |
|
105 return KErrNone; |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CWlanObserver::DoCancel |
|
110 // ----------------------------------------------------------------------------- |
|
111 void CWlanObserver::DoCancel() |
|
112 { |
|
113 iWlanProperty.Cancel(); |
|
114 } |
|
115 |
|
116 // End of File |